diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-11-02 13:38:19 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-11-02 13:42:53 -0400 |
| commit | 77f750496d9e6e0f9301646f4066dc53e4ad7fab (patch) | |
| tree | 42adeefe72ca9875cd06d38b6d125625c176d492 /ui/lib/apiServer.js | |
| parent | a238cd143efac9f2f9cd77afc2a407840318b0b1 (diff) | |
Remove notification permissions prompt.
On Safari (iOS and macOS), the permissions prompt can only be done during a user gesture; mounting is sufficiently disconnected from any user gestures that it's not allowed. The browser raises an exception, which, since it is unhandled, then leaks out and interrupts SvelteKit's element unmounting, leading to the whole UI being duplicated when switching channels (the old UI is not unmounted).
Diffstat (limited to 'ui/lib/apiServer.js')
| -rw-r--r-- | ui/lib/apiServer.js | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/ui/lib/apiServer.js b/ui/lib/apiServer.js index 3e270fc..5c6e5ef 100644 --- a/ui/lib/apiServer.js +++ b/ui/lib/apiServer.js @@ -1,6 +1,5 @@ import axios from 'axios'; -import { get } from 'svelte/store'; -import { currentUser, channelsList, logins, messages } from '$lib/store'; +import { channelsList, logins, messages } from '$lib/store'; export const apiServer = axios.create({ baseURL: '/api/', @@ -116,33 +115,9 @@ function onMessageEvent(data) { switch (data.event) { case 'sent': messages.update((value) => value.addMessage(data.channel, data.id, data.at, data.sender, data.body)); - displayToast(data); break; case 'deleted': messages.update((value) => value.deleteMessage(data.id)); break; } } - -function displayToast(data) { - // we use get throughout this as this function is not reactive, and just - // needs the values of the stores at a moment in time. - const currentUserId = get(currentUser).id; - if (currentUserId === data.sender) { - return; - } - - const senderName = get(logins).get(data.sender); - const channelName = get(channelsList).get(data.channel); - const title = `${senderName} in ${channelName}`; - - const opts = { - body: data.body, - tag: title, - // TODO: we need to inject the understory/hi icon in a more principled way here: - icon: "/ui/lib/assets/logo.png", - // TODO: support onclick bringing you to the relevant channel? - onclick: null - } - new Notification(title, opts); -} |
