refactor (client): compare Firefish versions lexicographically
This commit is contained in:
parent
ba48f063a5
commit
80e3e0e91d
4 changed files with 3 additions and 31 deletions
|
@ -40,7 +40,6 @@ import { i18n } from "@/i18n";
|
||||||
import { fetchInstance, instance } from "@/instance";
|
import { fetchInstance, instance } from "@/instance";
|
||||||
import { isSignedIn, me } from "@/me";
|
import { isSignedIn, me } from "@/me";
|
||||||
import { alert, api, confirm, popup, post, toast } from "@/os";
|
import { alert, api, confirm, popup, post, toast } from "@/os";
|
||||||
import { compareFirefishVersions } from "@/scripts/compare-versions";
|
|
||||||
import { deviceKind } from "@/scripts/device-kind";
|
import { deviceKind } from "@/scripts/device-kind";
|
||||||
import { getAccountFromId } from "@/scripts/get-account-from-id";
|
import { getAccountFromId } from "@/scripts/get-account-from-id";
|
||||||
import { makeHotkey } from "@/scripts/hotkey";
|
import { makeHotkey } from "@/scripts/hotkey";
|
||||||
|
@ -246,11 +245,7 @@ function checkForSplash() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 変なバージョン文字列来るとcompareVersionsでエラーになるため
|
// 変なバージョン文字列来るとcompareVersionsでエラーになるため
|
||||||
if (
|
if (lastVersion < version && defaultStore.state.showUpdates) {
|
||||||
lastVersion != null &&
|
|
||||||
compareFirefishVersions(lastVersion, version) === 1 &&
|
|
||||||
defaultStore.state.showUpdates
|
|
||||||
) {
|
|
||||||
// ログインしてる場合だけ
|
// ログインしてる場合だけ
|
||||||
if (me) {
|
if (me) {
|
||||||
popup(
|
popup(
|
||||||
|
|
|
@ -85,7 +85,6 @@ import {
|
||||||
provideMetadataReceiver,
|
provideMetadataReceiver,
|
||||||
} from "@/scripts/page-metadata";
|
} from "@/scripts/page-metadata";
|
||||||
import icon from "@/scripts/icon";
|
import icon from "@/scripts/icon";
|
||||||
import { compareFirefishVersions } from "@/scripts/compare-versions";
|
|
||||||
|
|
||||||
const isEmpty = (x: string | null) => x == null || x === "";
|
const isEmpty = (x: string | null) => x == null || x === "";
|
||||||
const el = ref<HTMLElement | null>(null);
|
const el = ref<HTMLElement | null>(null);
|
||||||
|
@ -122,8 +121,7 @@ os.api("admin/abuse-user-reports", {
|
||||||
|
|
||||||
if (defaultStore.state.showAdminUpdates) {
|
if (defaultStore.state.showAdminUpdates) {
|
||||||
os.api("latest-version").then((res) => {
|
os.api("latest-version").then((res) => {
|
||||||
updateAvailable.value =
|
updateAvailable.value = version < res?.latest_version;
|
||||||
compareFirefishVersions(version, res?.latest_version) === 1;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
const less = -1;
|
|
||||||
const same = 0;
|
|
||||||
const more = 1;
|
|
||||||
|
|
||||||
export const compareFirefishVersions = (
|
|
||||||
oldVersion: string,
|
|
||||||
newVersion: string,
|
|
||||||
) => {
|
|
||||||
if (oldVersion === newVersion) return same;
|
|
||||||
|
|
||||||
const o = oldVersion.split("-");
|
|
||||||
const n = newVersion.split("-");
|
|
||||||
|
|
||||||
if (o[0] < n[0]) return more;
|
|
||||||
if (o[0] === n[0] && o[1] == null && n[1] != null) return more;
|
|
||||||
if (o[0] === n[0] && o[1] != null && n[1] != null && o[1] < n[1]) return more;
|
|
||||||
|
|
||||||
return less;
|
|
||||||
};
|
|
|
@ -162,7 +162,6 @@ import { i18n } from "@/i18n";
|
||||||
import { instance } from "@/instance";
|
import { instance } from "@/instance";
|
||||||
import { version } from "@/config";
|
import { version } from "@/config";
|
||||||
import icon from "@/scripts/icon";
|
import icon from "@/scripts/icon";
|
||||||
import { compareFirefishVersions } from "@/scripts/compare-versions";
|
|
||||||
|
|
||||||
const isEmpty = (x: string | null) => x == null || x === "";
|
const isEmpty = (x: string | null) => x == null || x === "";
|
||||||
|
|
||||||
|
@ -212,8 +211,7 @@ if (isAdmin) {
|
||||||
|
|
||||||
if (defaultStore.state.showAdminUpdates) {
|
if (defaultStore.state.showAdminUpdates) {
|
||||||
os.api("latest-version").then((res) => {
|
os.api("latest-version").then((res) => {
|
||||||
updateAvailable.value =
|
updateAvailable.value = version < res?.latest_version;
|
||||||
compareFirefishVersions(version, res?.latest_version) === 1;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue