fixup! Add webpush front-end support

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-05-06 18:50:02 +02:00
parent 2c29a837ad
commit 6eb81ca253
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
1 changed files with 5 additions and 3 deletions

View File

@ -21,7 +21,7 @@
<b-button
icon-left="rss"
@click="subscribeToWebPush"
v-if="!canShowWebPush"
v-if="canShowWebPush()"
>{{ $t("WebPush") }}</b-button
>
<span v-else>{{ $t("You can't use webpush in this browser.") }}</span>
@ -317,14 +317,16 @@ export default class Notifications extends Vue {
}
async subscribeToWebPush(): Promise<void> {
if (window.isSecureContext && navigator.serviceWorker) {
if (this.canShowWebPush()) {
const a = await subscribeUserToPush();
console.log(a);
} else {
console.log("can't do webpush");
}
}
canShowWebPush(): boolean {
return !!window.isSecureContext && !!navigator.serviceWorker;
return window.isSecureContext && !!navigator.serviceWorker;
}
private async deleteFeedToken(token: string): Promise<void> {