Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added loading component in pushNotification.vue component #1583

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/components/participant/ActionInputs/PushNotification.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<b-card no-body class="action-wrap">
<loading
:active.sync="isLoading"
:can-cancel="true"
:is-full-page="fullPage"
></loading>
<b-card-header
:class="visible ? null : 'collapsed'"
:aria-expanded="visible ? 'true' : 'false'"
Expand Down Expand Up @@ -73,9 +78,12 @@ import eventBus from "../../../eventBus.js";
import { isValidURL, isEmpty } from "../../../mixins/fieldValidationMixin";
import notificationMixins from "../../../mixins/notificationMixins";
import Messages from "../../../utils/messages/participants/en";
import Loading from "vue-loading-overlay";
import "vue-loading-overlay/dist/vue-loading.css";
import config from "../../../config";
export default {
name: "PushNotification",
components:{ Loading },
props: {
idValue: {
required: true,
Expand Down Expand Up @@ -104,6 +112,8 @@ computed:{
data() {
return {
visible: false,
isLoading: false,
fullPage: true,
};
},
mounted() {
Expand Down Expand Up @@ -195,6 +205,7 @@ computed:{
},
async getBrowserSubscription() {
this.isLoading = true;
if ("Notification" in window && navigator.serviceWorker) {
const permission = await Notification.requestPermission();
if (permission === "granted") {
Expand All @@ -208,6 +219,7 @@ computed:{
);
}
} catch (error) {
this.isLoading = false;
console.log("Not Brave");
}
Expand All @@ -234,20 +246,25 @@ computed:{
this.data.subscription = await this.saveSubscription(e);
// console.log(e);
localStorage.setItem("subsId", this.data.subscription._id);
});
}).catch((e) => {
this.isLoading = false;
})
});
await this.notifySuccess("Registerd");
} catch (error) {
// console.log(error);
this.isLoading = false;
return this.notifyErr("Service Worker Registration Faild");
}
} else if (permission === "blocked" || permission === "denied") {
this.isLoading = false;
return this.notifyErr("Notification Blocked");
}
} else {
this.isLoading = false;
return this.notifyErr("Notification Not Supported");
}
this.isLoading = false;
},
},
mixins: [notificationMixins],
Expand Down