fix (api): fetch latest version from new repository

This commit is contained in:
naskya 2024-02-12 02:49:36 +09:00
parent ba1e2898de
commit dc66474eef
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
4 changed files with 10 additions and 6 deletions

View file

@ -2,6 +2,10 @@
Breaking changes are indicated by the :warning: icon.
## Unreleased
- :warning: The field name of the response of `latest-version` has been changed from `tag_name` to `latest_version`.
## v1.0.5-rc
- `admin/update-meta` can now take `moreUrls` parameter, and response of `admin/meta` now includes `moreUrls`

View file

@ -14,14 +14,14 @@ export const paramDef = {
} as const;
export default define(meta, paramDef, async () => {
let tag_name;
await fetch("https://git.joinfirefish.org/api/v4/projects/7/releases")
let latest_version;
await fetch("https://firefish.dev/firefish/firefish/-/raw/main/package.json")
.then((response) => response.json())
.then((data) => {
tag_name = data[0].tag_name;
latest_version = data.version;
});
return {
tag_name,
latest_version,
};
});

View file

@ -122,7 +122,7 @@ os.api("admin/abuse-user-reports", {
if (defaultStore.state.showAdminUpdates) {
os.api("latest-version").then((res) => {
const cleanRes = parseInt(res?.tag_name.replace(/[^0-9]/g, ""));
const cleanRes = parseInt(res?.latest_version.replace(/[^0-9]/g, ""));
const cleanVersion = parseInt(version.replace(/[^0-9]/g, ""));
if (cleanRes > cleanVersion) {
updateAvailable.value = true;

View file

@ -206,7 +206,7 @@ if (isAdmin) {
if (defaultStore.state.showAdminUpdates) {
os.api("latest-version").then((res) => {
const cleanRes = parseInt(res?.tag_name.replace(/[^0-9]/g, ""));
const cleanRes = parseInt(res?.latest_version.replace(/[^0-9]/g, ""));
const cleanVersion = parseInt(version.replace(/[^0-9]/g, ""));
if (cleanRes > cleanVersion) {
updateAvailable.value = true;