This commit is contained in:
Bryan1029384756
2026-04-18 15:41:51 -05:00
parent 938df217f4
commit 593eaba82e
47 changed files with 3539 additions and 212 deletions

View File

@@ -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',
},
};