2022-02-19 00:45:25 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2022-06-19 00:25:21 +00:00
|
|
|
<template v-if="!store.state.serverConfiguration?.public">
|
2022-02-19 00:45:25 +00:00
|
|
|
<h2>Push Notifications</h2>
|
|
|
|
<div>
|
|
|
|
<button
|
|
|
|
id="pushNotifications"
|
|
|
|
type="button"
|
|
|
|
class="btn"
|
|
|
|
:disabled="
|
2022-06-19 00:25:21 +00:00
|
|
|
store.state.pushNotificationState !== 'supported' &&
|
|
|
|
store.state.pushNotificationState !== 'subscribed'
|
2022-02-19 00:45:25 +00:00
|
|
|
"
|
|
|
|
@click="onPushButtonClick"
|
|
|
|
>
|
2022-06-19 00:25:21 +00:00
|
|
|
<template v-if="store.state.pushNotificationState === 'subscribed'">
|
2022-02-19 00:45:25 +00:00
|
|
|
Unsubscribe from push notifications
|
|
|
|
</template>
|
2022-06-19 00:25:21 +00:00
|
|
|
<template v-else-if="store.state.pushNotificationState === 'loading'">
|
2022-02-19 00:45:25 +00:00
|
|
|
Loading…
|
|
|
|
</template>
|
|
|
|
<template v-else> Subscribe to push notifications </template>
|
|
|
|
</button>
|
2022-06-19 00:25:21 +00:00
|
|
|
<div v-if="store.state.pushNotificationState === 'nohttps'" class="error">
|
2022-02-19 00:45:25 +00:00
|
|
|
<strong>Warning</strong>: Push notifications are only supported over HTTPS
|
|
|
|
connections.
|
|
|
|
</div>
|
2022-06-19 00:25:21 +00:00
|
|
|
<div v-if="store.state.pushNotificationState === 'unsupported'" class="error">
|
2022-02-19 00:45:25 +00:00
|
|
|
<strong>Warning</strong>:
|
|
|
|
<span>Push notifications are not supported by your browser.</span>
|
|
|
|
|
|
|
|
<div v-if="isIOS" class="apple-push-unsupported">
|
|
|
|
Safari does
|
|
|
|
<a
|
|
|
|
href="https://bugs.webkit.org/show_bug.cgi?id=182566"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener"
|
|
|
|
>not support the web push notification specification</a
|
|
|
|
>, and because all browsers on iOS use Safari under the hood, The Lounge is
|
|
|
|
unable to provide push notifications on iOS devices.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<h2>Browser Notifications</h2>
|
|
|
|
<div>
|
|
|
|
<label class="opt">
|
|
|
|
<input
|
|
|
|
id="desktopNotifications"
|
2022-06-19 00:25:21 +00:00
|
|
|
:checked="store.state.settings.desktopNotifications"
|
|
|
|
:disabled="store.state.desktopNotificationState === 'nohttps'"
|
2022-02-19 00:45:25 +00:00
|
|
|
type="checkbox"
|
|
|
|
name="desktopNotifications"
|
|
|
|
/>
|
|
|
|
Enable browser notifications<br />
|
2022-06-19 00:25:21 +00:00
|
|
|
<div v-if="store.state.desktopNotificationState === 'unsupported'" class="error">
|
2022-02-19 00:45:25 +00:00
|
|
|
<strong>Warning</strong>: Notifications are not supported by your browser.
|
|
|
|
</div>
|
|
|
|
<div
|
2022-06-19 00:25:21 +00:00
|
|
|
v-if="store.state.desktopNotificationState === 'nohttps'"
|
2022-02-19 00:45:25 +00:00
|
|
|
id="warnBlockedDesktopNotifications"
|
|
|
|
class="error"
|
|
|
|
>
|
|
|
|
<strong>Warning</strong>: Notifications are only supported over HTTPS
|
|
|
|
connections.
|
|
|
|
</div>
|
|
|
|
<div
|
2022-06-19 00:25:21 +00:00
|
|
|
v-if="store.state.desktopNotificationState === 'blocked'"
|
2022-02-19 00:45:25 +00:00
|
|
|
id="warnBlockedDesktopNotifications"
|
|
|
|
class="error"
|
|
|
|
>
|
|
|
|
<strong>Warning</strong>: Notifications are blocked by your browser.
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label class="opt">
|
|
|
|
<input
|
2022-06-19 00:25:21 +00:00
|
|
|
:checked="store.state.settings.notification"
|
2022-02-19 00:45:25 +00:00
|
|
|
type="checkbox"
|
|
|
|
name="notification"
|
|
|
|
/>
|
|
|
|
Enable notification sound
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div class="opt">
|
|
|
|
<button id="play" @click.prevent="playNotification">Play sound</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<label class="opt">
|
|
|
|
<input
|
2022-06-19 00:25:21 +00:00
|
|
|
:checked="store.state.settings.notifyAllMessages"
|
2022-02-19 00:45:25 +00:00
|
|
|
type="checkbox"
|
|
|
|
name="notifyAllMessages"
|
|
|
|
/>
|
|
|
|
Enable notification for all messages
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
<div v-if="!store.state.serverConfiguration?.public">
|
2022-02-19 00:45:25 +00:00
|
|
|
<label class="opt">
|
|
|
|
<label for="highlights" class="opt">
|
|
|
|
Custom highlights
|
|
|
|
<span
|
|
|
|
class="tooltipped tooltipped-n tooltipped-no-delay"
|
|
|
|
aria-label="If a message contains any of these comma-separated
|
|
|
|
expressions, it will trigger a highlight."
|
|
|
|
>
|
|
|
|
<button class="extra-help" />
|
|
|
|
</span>
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
id="highlights"
|
2022-06-19 00:25:21 +00:00
|
|
|
:value="store.state.settings.highlights"
|
2022-02-19 00:45:25 +00:00
|
|
|
type="text"
|
|
|
|
name="highlights"
|
|
|
|
class="input"
|
|
|
|
autocomplete="off"
|
|
|
|
placeholder="Comma-separated, e.g.: word, some more words, anotherword"
|
|
|
|
/>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
<div v-if="!store.state.serverConfiguration?.public">
|
2022-02-19 00:45:25 +00:00
|
|
|
<label class="opt">
|
|
|
|
<label for="highlightExceptions" class="opt">
|
|
|
|
Highlight exceptions
|
|
|
|
<span
|
|
|
|
class="tooltipped tooltipped-n tooltipped-no-delay"
|
|
|
|
aria-label="If a message contains any of these comma-separated
|
|
|
|
expressions, it will not trigger a highlight even if it contains
|
|
|
|
your nickname or expressions defined in custom highlights."
|
|
|
|
>
|
|
|
|
<button class="extra-help" />
|
|
|
|
</span>
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
id="highlightExceptions"
|
2022-06-19 00:25:21 +00:00
|
|
|
:value="store.state.settings.highlightExceptions"
|
2022-02-19 00:45:25 +00:00
|
|
|
type="text"
|
|
|
|
name="highlightExceptions"
|
|
|
|
class="input"
|
|
|
|
autocomplete="off"
|
|
|
|
placeholder="Comma-separated, e.g.: word, some more words, anotherword"
|
|
|
|
/>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import {computed, defineComponent} from "vue";
|
|
|
|
import {useStore} from "../../js/store";
|
2022-02-19 00:45:25 +00:00
|
|
|
import webpush from "../../js/webpush";
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
export default defineComponent({
|
2022-02-19 00:45:25 +00:00
|
|
|
name: "NotificationSettings",
|
2022-06-19 00:25:21 +00:00
|
|
|
setup() {
|
|
|
|
const store = useStore();
|
|
|
|
|
|
|
|
const isIOS = computed(
|
|
|
|
() =>
|
2022-02-19 00:45:25 +00:00
|
|
|
[
|
|
|
|
"iPad Simulator",
|
|
|
|
"iPhone Simulator",
|
|
|
|
"iPod Simulator",
|
|
|
|
"iPad",
|
|
|
|
"iPhone",
|
|
|
|
"iPod",
|
|
|
|
].includes(navigator.platform) ||
|
|
|
|
// iPad on iOS 13 detection
|
2022-06-19 00:25:21 +00:00
|
|
|
(navigator.userAgent.includes("Mac") && "ontouchend" in document)
|
|
|
|
);
|
|
|
|
|
|
|
|
const playNotification = () => {
|
2022-02-19 00:45:25 +00:00
|
|
|
const pop = new Audio();
|
|
|
|
pop.src = "audio/pop.wav";
|
2022-06-19 00:25:21 +00:00
|
|
|
|
|
|
|
// eslint-disable-next-line
|
2022-02-19 00:45:25 +00:00
|
|
|
pop.play();
|
2022-06-19 00:25:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const onPushButtonClick = () => {
|
2022-02-19 00:45:25 +00:00
|
|
|
webpush.togglePushSubscription();
|
2022-06-19 00:25:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
isIOS,
|
|
|
|
store,
|
|
|
|
playNotification,
|
|
|
|
onPushButtonClick,
|
|
|
|
};
|
2022-02-19 00:45:25 +00:00
|
|
|
},
|
2022-06-19 00:25:21 +00:00
|
|
|
});
|
2022-02-19 00:45:25 +00:00
|
|
|
</script>
|