(title, description, href)
| 55 | const writeDefaultServerUrl = (url: string | null) => setStorage(DEFAULT_SERVER_URL_KEY, url) |
| 56 | |
| 57 | const notify: Platform["notify"] = async (title, description, href) => { |
| 58 | if (!("Notification" in window)) return |
| 59 | |
| 60 | const permission = |
| 61 | Notification.permission === "default" |
| 62 | ? await Notification.requestPermission().catch(() => "denied") |
| 63 | : Notification.permission |
| 64 | |
| 65 | if (permission !== "granted") return |
| 66 | |
| 67 | const inView = document.visibilityState === "visible" && document.hasFocus() |
| 68 | if (inView) return |
| 69 | |
| 70 | const notification = new Notification(title, { |
| 71 | body: description ?? "", |
| 72 | icon: "https://opencode.ai/favicon-96x96-v3.png", |
| 73 | }) |
| 74 | |
| 75 | notification.onclick = () => { |
| 76 | handleNotificationClick(href) |
| 77 | notification.close() |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | const openLink: Platform["openLink"] = (url) => { |
| 82 | window.open(url, "_blank") |
no test coverage detected