1.1.3
This commit is contained in:
@@ -11,6 +11,50 @@ import SearchDatabase from '@discord-clone/shared/src/utils/SearchDatabase';
|
||||
|
||||
const searchDB = new SearchDatabase(searchStorage, crypto);
|
||||
|
||||
function makeWebNotifications() {
|
||||
if (typeof window === 'undefined' || typeof window.Notification === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
show({ title, body, silent }) {
|
||||
if (Notification.permission !== 'granted') return;
|
||||
try {
|
||||
const n = new Notification(String(title ?? 'Brycord'), {
|
||||
body: String(body ?? ''),
|
||||
silent: !!silent,
|
||||
});
|
||||
n.onclick = () => {
|
||||
try { window.focus(); } catch {}
|
||||
try { n.close(); } catch {}
|
||||
};
|
||||
} catch {}
|
||||
},
|
||||
// Web has the Badging API on some browsers (Chrome, Edge). No-op
|
||||
// where unavailable instead of throwing.
|
||||
setBadge(count) {
|
||||
const n = Math.max(0, Math.floor(Number(count) || 0));
|
||||
try {
|
||||
if (n === 0) navigator.clearAppBadge?.();
|
||||
else navigator.setAppBadge?.(n);
|
||||
} catch {}
|
||||
},
|
||||
// Web has no taskbar-flash equivalent — title bounce is the
|
||||
// closest thing but gets intrusive fast. No-op for now.
|
||||
flashFrame() {},
|
||||
async ensurePermission() {
|
||||
if (!('Notification' in window)) return 'unavailable';
|
||||
if (Notification.permission === 'granted') return 'granted';
|
||||
if (Notification.permission === 'denied') return 'denied';
|
||||
try {
|
||||
const result = await Notification.requestPermission();
|
||||
return result;
|
||||
} catch {
|
||||
return 'default';
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const webPlatform = {
|
||||
crypto,
|
||||
session,
|
||||
@@ -34,6 +78,7 @@ const webPlatform = {
|
||||
},
|
||||
},
|
||||
windowControls: null,
|
||||
notifications: makeWebNotifications(),
|
||||
recording: null,
|
||||
updates: null,
|
||||
voiceService: null,
|
||||
@@ -47,6 +92,7 @@ const webPlatform = {
|
||||
hasVoiceService: false,
|
||||
hasSystemBars: false,
|
||||
hasRecording: false,
|
||||
hasNotifications: typeof window !== 'undefined' && typeof window.Notification !== 'undefined',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user