mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Allow custom release URL.
This commit is contained in:
parent
64f1841ae4
commit
e4c4019e25
7 changed files with 27 additions and 21 deletions
|
|
@ -1,16 +1,15 @@
|
|||
import create from 'zustand';
|
||||
import produce from 'immer';
|
||||
import semver from 'semver';
|
||||
import { VERSION_CHECK } from 'lib/constants';
|
||||
import { VERSION_CHECK, UPDATES_URL } from 'lib/constants';
|
||||
import { getItem } from 'lib/web';
|
||||
|
||||
const UPDATES_URL = 'https://api.umami.is/v1/updates';
|
||||
|
||||
const initialState = {
|
||||
current: process.env.currentVersion,
|
||||
latest: null,
|
||||
hasUpdate: false,
|
||||
checked: false,
|
||||
releaseUrl: null,
|
||||
};
|
||||
|
||||
const store = create(() => ({ ...initialState }));
|
||||
|
|
@ -37,7 +36,7 @@ export async function checkVersion() {
|
|||
|
||||
store.setState(
|
||||
produce(state => {
|
||||
const { latest } = data;
|
||||
const { latest, url } = data;
|
||||
const lastCheck = getItem(VERSION_CHECK);
|
||||
|
||||
const hasUpdate = !!(latest && lastCheck?.version !== latest && semver.gt(latest, current));
|
||||
|
|
@ -46,6 +45,7 @@ export async function checkVersion() {
|
|||
state.latest = latest;
|
||||
state.hasUpdate = hasUpdate;
|
||||
state.checked = true;
|
||||
state.releaseUrl = url;
|
||||
|
||||
return state;
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue