mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat(web): re-add version announcement (#1887)
* feat(web): re-add version announcement * show notification for every update
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
type CheckAppVersionReponse = {
|
||||
shouldShowAnnouncement: boolean;
|
||||
localVersion?: string;
|
||||
remoteVersion?: string;
|
||||
};
|
||||
|
||||
type GithubRelease = {
|
||||
tag_name: string;
|
||||
};
|
||||
|
||||
export const checkAppVersion = async (): Promise<CheckAppVersionReponse> => {
|
||||
const res = await fetch('https://api.github.com/repos/immich-app/immich/releases/latest', {
|
||||
headers: {
|
||||
Accept: 'application/vnd.github.v3+json'
|
||||
}
|
||||
});
|
||||
|
||||
if (res.status == 200) {
|
||||
const latestRelease = (await res.json()) as GithubRelease;
|
||||
const appVersion = localStorage.getItem('appVersion');
|
||||
|
||||
if (!appVersion) {
|
||||
return {
|
||||
shouldShowAnnouncement: false,
|
||||
remoteVersion: latestRelease.tag_name,
|
||||
localVersion: 'empty'
|
||||
};
|
||||
}
|
||||
|
||||
if (appVersion != latestRelease.tag_name) {
|
||||
return {
|
||||
shouldShowAnnouncement: true,
|
||||
remoteVersion: latestRelease.tag_name,
|
||||
localVersion: appVersion
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
shouldShowAnnouncement: false,
|
||||
remoteVersion: latestRelease.tag_name,
|
||||
localVersion: appVersion
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
shouldShowAnnouncement: false,
|
||||
remoteVersion: '0',
|
||||
localVersion: '0'
|
||||
};
|
||||
}
|
||||
};
|
||||
18
web/src/lib/utils/get-github-version.ts
Normal file
18
web/src/lib/utils/get-github-version.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import axios from 'axios';
|
||||
|
||||
type GithubRelease = {
|
||||
tag_name: string;
|
||||
};
|
||||
|
||||
export const getGithubVersion = async (): Promise<string> => {
|
||||
const { data } = await axios.get<GithubRelease>(
|
||||
'https://api.github.com/repos/immich-app/immich/releases/latest',
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/vnd.github.v3+json'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return data.tag_name;
|
||||
};
|
||||
Reference in New Issue
Block a user