Skip to content

Commit

Permalink
Fix & Feat Client App [Notification]
Browse files Browse the repository at this point in the history
[+] fix(update.ts): remove unnecessary notification sending when permission is not granted
[+] feat(update.ts): add notification for already up to date version
  • Loading branch information
H0llyW00dzZ committed Oct 3, 2023
1 parent d2ad01a commit ddfd05b
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions app/store/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,28 @@ export const useUpdateStore = createPersistStore(
// Check if notification permission is granted
await window.__TAURI__?.notification.isPermissionGranted().then((granted) => {
if (!granted) {
// Send a notification without waiting for permission (because we don't neeed a permisison once client is already click "check")
window.__TAURI__?.notification.sendNotification({
title: "ChatGPT Next Web",
body: `A new version (${remoteId}) is available.`,
icon: `${ChatGptIcon.src}`,
sound: "Default"
});
return
} else {
// Request permission to show notifications
window.__TAURI__?.notification.requestPermission().then((permission) => {
if (permission === 'granted') {
// Show a notification using Tauri
window.__TAURI__?.notification.sendNotification({
title: "ChatGPT Next Web",
body: `A new version (${remoteId}) is available.`,
icon: `${ChatGptIcon.src}`,
sound: "Default"
});
if (version === remoteId) {
// Show a notification using Tauri
window.__TAURI__?.notification.sendNotification({
title: "ChatGPT Next Web",
body: "Already up to date",
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"
});
}
}
});
}
Expand Down

0 comments on commit ddfd05b

Please sign in to comment.