From 44aa70ca5554f47398667081182ea11122a052a3 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 22 Feb 2024 03:14:41 +0900 Subject: [PATCH] fix (client): update version comparison algorithm --- packages/client/src/init.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index d070e2048b..b284a7806c 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -22,7 +22,6 @@ if (accounts) { } // #endregion -import { compareVersions } from "compare-versions"; import { computed, createApp, @@ -251,11 +250,23 @@ function checkForSplash() { // テーマリビルドするため localStorage.removeItem("theme"); + const isUpdated = (prevVersion: string, currentVersion: string) => { + const p = prevVersion.split("-"); + const c = currentVersion.split("-"); + + if (p[0] < c[0]) return true; + if (p[0] === c[0] && p[1] == null && c[1] != null) return true; + if (p[0] === c[0] && p[1] != null && c[1] != null && p[1] < c[1]) + return true; + + return false; + }; + try { // 変なバージョン文字列来るとcompareVersionsでエラーになるため if ( lastVersion != null && - compareVersions(version, lastVersion) === 1 && + isUpdated(lastVersion, version) && defaultStore.state.showUpdates ) { // ログインしてる場合だけ