forked from XiaoMo/ChatGPT-Next-Web
Fix & Feat Client App [Notification]
[+] fix(update.ts): remove unnecessary notification sending when permission is not granted [+] feat(update.ts): add notification for already up to date version
This commit is contained in:
parent
d2ad01a9ff
commit
ddfd05b008
@ -86,24 +86,28 @@ export const useUpdateStore = createPersistStore(
|
|||||||
// Check if notification permission is granted
|
// Check if notification permission is granted
|
||||||
await window.__TAURI__?.notification.isPermissionGranted().then((granted) => {
|
await window.__TAURI__?.notification.isPermissionGranted().then((granted) => {
|
||||||
if (!granted) {
|
if (!granted) {
|
||||||
// Send a notification without waiting for permission (because we don't neeed a permisison once client is already click "check")
|
return
|
||||||
window.__TAURI__?.notification.sendNotification({
|
|
||||||
title: "ChatGPT Next Web",
|
|
||||||
body: `A new version (${remoteId}) is available.`,
|
|
||||||
icon: `${ChatGptIcon.src}`,
|
|
||||||
sound: "Default"
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
// Request permission to show notifications
|
// Request permission to show notifications
|
||||||
window.__TAURI__?.notification.requestPermission().then((permission) => {
|
window.__TAURI__?.notification.requestPermission().then((permission) => {
|
||||||
if (permission === 'granted') {
|
if (permission === 'granted') {
|
||||||
// Show a notification using Tauri
|
if (version === remoteId) {
|
||||||
window.__TAURI__?.notification.sendNotification({
|
// Show a notification using Tauri
|
||||||
title: "ChatGPT Next Web",
|
window.__TAURI__?.notification.sendNotification({
|
||||||
body: `A new version (${remoteId}) is available.`,
|
title: "ChatGPT Next Web",
|
||||||
icon: `${ChatGptIcon.src}`,
|
body: "Already up to date",
|
||||||
sound: "Default"
|
icon: `${ChatGptIcon.src}`,
|
||||||
});
|
sound: "Default"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Show a notification for the new version using Tauri
|
||||||
|
window.__TAURI__?.notification.sendNotification({
|
||||||
|
title: "ChatGPT Next Web",
|
||||||
|
body: `A new version (${remoteId}) is available.`,
|
||||||
|
icon: `${ChatGptIcon.src}`,
|
||||||
|
sound: "Default"
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user