From 6daf221513c5e57dc7ff4c41f3a0e174b0d76fb0 Mon Sep 17 00:00:00 2001 From: Marco Rodolfi Date: Fri, 9 Aug 2024 10:01:17 +0200 Subject: [PATCH] Rebase semver parsing on main --- frontend/package.json | 3 ++- frontend/pnpm-lock.yaml | 8 ++++++++ frontend/src/store.tsx | 12 +++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 25c70ff12..b972a7a36 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -55,6 +55,7 @@ "react-i18next": "^14.1.2", "react-icons": "^5.2.1", "react-markdown": "^9.0.1", - "remark-gfm": "^4.0.0" + "remark-gfm": "^4.0.0", + "compare-versions": "^6.1.1" } } diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 61de89afe..d61861705 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@decky/ui': specifier: ^4.7.1 version: 4.7.1 + compare-versions: + specifier: ^6.1.1 + version: 6.1.1 filesize: specifier: ^10.1.2 version: 10.1.2 @@ -848,6 +851,9 @@ packages: commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} + compare-versions@6.1.1: + resolution: {integrity: sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg==} + concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} @@ -2816,6 +2822,8 @@ snapshots: commondir@1.0.1: {} + compare-versions@6.1.1: {} + concat-map@0.0.1: {} convert-source-map@2.0.0: {} diff --git a/frontend/src/store.tsx b/frontend/src/store.tsx index 8ab8f50a3..5391a15a9 100644 --- a/frontend/src/store.tsx +++ b/frontend/src/store.tsx @@ -1,3 +1,5 @@ +import { compare } from 'compare-versions'; + import { InstallType, Plugin, installPlugin, installPlugins } from './plugin'; import { getSetting, setSetting } from './utils/settings'; @@ -137,7 +139,15 @@ export async function checkForPluginUpdates(plugins: Plugin[]): Promise(); for (let plugin of plugins) { const remotePlugin = serverData?.find((x) => x.name == plugin.name); - if (remotePlugin && remotePlugin.versions?.length > 0 && plugin.version != remotePlugin?.versions?.[0]?.name) { + //FIXME: Ugly hack since plugin.version might be null during evaluation, + //so this will set the older version possible + const curVer = plugin.version ? plugin.version : '0.0'; + if ( + remotePlugin && + remotePlugin.versions?.length > 0 && + plugin.version != remotePlugin?.versions?.[0]?.name && + compare(remotePlugin?.versions?.[0]?.name, curVer, '>') + ) { updateMap.set(plugin.name, remotePlugin.versions[0]); } }