Skip to content

Commit 3c03cea

Browse files
authored
Fix the ESS version not loading after a refresh (#129)
Because we started saving query responses in IndexedDB, sometimes we returned classes, which wouldn't get persisted correctly. This meant that the dashboard wouldn't load after a page refresh
2 parents cab2a2e + a3618b6 commit 3c03cea

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/api/ess.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ import { accessToken } from "@/stores/auth";
1111
import { ensureResponseOk, fetch } from "@/utils/fetch";
1212

1313
const VersionResponse = v.object({
14-
version: v.fallback(
15-
v.nullable(
16-
v.pipe(
17-
v.string(),
18-
v.transform((version) => parseSemver(version, true, false)),
19-
),
20-
),
21-
null,
22-
),
14+
version: v.nullable(v.string()),
2315
edition: v.fallback(v.nullable(v.picklist(["community", "pro"])), null),
2416
});
2517

@@ -64,5 +56,6 @@ export const useEssVariant = (
6456

6557
export const useEssVersion = (synapseRoot: string): null | SemVer => {
6658
const { data } = useSuspenseQuery(essVersionQuery(synapseRoot));
67-
return data?.version;
59+
if (!data) return null;
60+
return parseSemver(data.version);
6861
};

src/api/github.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@
33
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
44

55
import { queryOptions } from "@tanstack/react-query";
6-
import parseSemver from "semver/functions/parse";
76
import * as v from "valibot";
87

98
import { ensureResponseOk, fetch } from "@/utils/fetch";
109

1110
const ReleaseResponse = v.object({
1211
html_url: v.string(),
1312
name: v.string(),
14-
// XXX: this parses the version from the tag as semver; maybe we want to do
15-
// that in a separate field?
16-
tag_name: v.pipe(
17-
v.string(),
18-
v.transform((version) => parseSemver(version, true, false)),
19-
),
13+
tag_name: v.string(),
2014
created_at: v.pipe(v.string(), v.isoTimestamp()),
2115
body: v.string(),
2216
});

0 commit comments

Comments
 (0)