Added auto-control on notification toggle -- be sure to empty browser cache in Storage to assure latest scripts are executing
This commit is contained in:
@@ -105,7 +105,12 @@
|
||||
<!-- toggle -->
|
||||
<div class="relative ml-2">
|
||||
<!-- input -->
|
||||
<input type="checkbox" name="toggleNotifications" class="sr-only" />
|
||||
<input
|
||||
type="checkbox"
|
||||
v-model="toggleNotifications"
|
||||
name="toggleNotifications"
|
||||
class="sr-only"
|
||||
/>
|
||||
<!-- line -->
|
||||
<div class="block bg-slate-500 w-14 h-8 rounded-full"></div>
|
||||
<!-- dot -->
|
||||
@@ -136,6 +141,7 @@
|
||||
type="checkbox"
|
||||
name="toggleMuteNotifications"
|
||||
class="sr-only"
|
||||
disabled
|
||||
/>
|
||||
<!-- line -->
|
||||
<div class="block bg-slate-500 w-14 h-8 rounded-full"></div>
|
||||
@@ -404,6 +410,16 @@ export default class AccountViewView extends Vue {
|
||||
|
||||
showAdvanced = false;
|
||||
|
||||
private isSubscribed = false;
|
||||
|
||||
get toggleNotifications() {
|
||||
return this.isSubscribed;
|
||||
}
|
||||
|
||||
set toggleNotifications(value) {
|
||||
this.isSubscribed = value;
|
||||
}
|
||||
|
||||
public async getIdentity(activeDid: string): Promise<IIdentifier | null> {
|
||||
try {
|
||||
// Open the accounts database
|
||||
@@ -486,6 +502,7 @@ export default class AccountViewView extends Vue {
|
||||
* @throws Will display specific messages to the user based on different errors.
|
||||
*/
|
||||
async created() {
|
||||
console.error("created");
|
||||
try {
|
||||
await db.open();
|
||||
|
||||
@@ -504,6 +521,18 @@ export default class AccountViewView extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
async mounted() {
|
||||
console.error("mounted()");
|
||||
try {
|
||||
const registration = await navigator.serviceWorker.ready;
|
||||
const subscription = await registration.pushManager.getSubscription();
|
||||
this.toggleNotifications = !!subscription;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.toggleNotifications = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes component state with values from the database or defaults.
|
||||
* @param {SettingsType} settings - Object containing settings from the database.
|
||||
@@ -711,7 +740,7 @@ export default class AccountViewView extends Vue {
|
||||
});
|
||||
this.isRegistered = true;
|
||||
} catch (err) {
|
||||
console.log("Got an error updating settings:", err);
|
||||
console.error("Got an error updating settings:", err);
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
@@ -753,10 +782,9 @@ export default class AccountViewView extends Vue {
|
||||
const data = error.response?.data as ErrorResponse;
|
||||
this.limitsMessage =
|
||||
(data?.error?.message as string) || "Bad server response.";
|
||||
console.log(
|
||||
console.error(
|
||||
"Got bad response retrieving limits, which usually means user isn't registered. Server says:",
|
||||
this.limitsMessage,
|
||||
//error,
|
||||
);
|
||||
} else if (
|
||||
error instanceof Error &&
|
||||
|
||||
Reference in New Issue
Block a user