Skip to content

Commit

Permalink
Merge pull request #226 from tloncorp/hm/fix-vere-version-parsing
Browse files Browse the repository at this point in the history
system preferences: fix vere version parsing
  • Loading branch information
jamesacklin authored Oct 6, 2023
2 parents deb800a + 38a936f commit 24e652c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ui/src/preferences/SystemPreferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const SystemPreferences = () => {
const { systemBlocked } = useSystemUpdate();
const charges = useCharges();
const filteredCharges = Object.values(charges).filter(
(charge) => charge.desk !== 'landscape' && charge.desk !== 'garden'
(charge) => charge.desk !== 'garden'
);
const isMobile = useMedia('(max-width: 639px)');

Expand Down
18 changes: 16 additions & 2 deletions ui/src/state/vere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ interface VereState {
nock?: number;
}

function parseVersion(versionPath: string | undefined) {
if (versionPath === undefined) {
return null;
}

const pattern = /~\.(\d+\.\d+)/gi;
const match = pattern.exec(versionPath);
if (!match) {
return null;
}

return match[1];
}

const useVereState = create<Vere>((set, get) => ({
cur: {
rev: '',
Expand All @@ -46,10 +60,10 @@ const fetchRuntimeVersion = () => {
useVereState.setState((state) => {
if (typeof data === 'object' && data !== null) {
const vereData = data as Vere;
const vereVersion = vereData.cur.rev.split('/')[3].substr(2);
const vereVersion = parseVersion(vereData.cur.rev);
const latestVereVersion =
vereData.next !== undefined
? vereData.next.rev.split('/')[2].substr(3)
? parseVersion(vereData.next.rev)
: vereVersion;
const isLatest =
vereVersion === latestVereVersion || vereData.next === undefined;
Expand Down

0 comments on commit 24e652c

Please sign in to comment.