fixup! Add webpush front-end support
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
2c29a837ad
commit
6eb81ca253
|
@ -21,7 +21,7 @@
|
||||||
<b-button
|
<b-button
|
||||||
icon-left="rss"
|
icon-left="rss"
|
||||||
@click="subscribeToWebPush"
|
@click="subscribeToWebPush"
|
||||||
v-if="!canShowWebPush"
|
v-if="canShowWebPush()"
|
||||||
>{{ $t("WebPush") }}</b-button
|
>{{ $t("WebPush") }}</b-button
|
||||||
>
|
>
|
||||||
<span v-else>{{ $t("You can't use webpush in this browser.") }}</span>
|
<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> {
|
async subscribeToWebPush(): Promise<void> {
|
||||||
if (window.isSecureContext && navigator.serviceWorker) {
|
if (this.canShowWebPush()) {
|
||||||
const a = await subscribeUserToPush();
|
const a = await subscribeUserToPush();
|
||||||
console.log(a);
|
console.log(a);
|
||||||
|
} else {
|
||||||
|
console.log("can't do webpush");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canShowWebPush(): boolean {
|
canShowWebPush(): boolean {
|
||||||
return !!window.isSecureContext && !!navigator.serviceWorker;
|
return window.isSecureContext && !!navigator.serviceWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async deleteFeedToken(token: string): Promise<void> {
|
private async deleteFeedToken(token: string): Promise<void> {
|
||||||
|
|
Loading…
Reference in New Issue