|
@ -105,27 +105,10 @@ |
|
|
</router-link> |
|
|
</router-link> |
|
|
|
|
|
|
|
|
<div class="bg-slate-100 rounded-md overflow-hidden px-4 py-4 mt-8 mb-8"> |
|
|
<div class="bg-slate-100 rounded-md overflow-hidden px-4 py-4 mt-8 mb-8"> |
|
|
<label |
|
|
<div |
|
|
v-if="notificationUnchanged" |
|
|
v-if="!notificationMaybeChanged" |
|
|
for="toggleNotifications" |
|
|
|
|
|
class="flex items-center justify-between cursor-pointer" |
|
|
class="flex items-center justify-between cursor-pointer" |
|
|
@click=" |
|
|
@click="showNotificationChoice()" |
|
|
!toggleNotifications |
|
|
|
|
|
? this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: 'modal', |
|
|
|
|
|
type: 'notification-permission', |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
) |
|
|
|
|
|
: this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: 'modal', |
|
|
|
|
|
type: 'notification-off', |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
) |
|
|
|
|
|
" |
|
|
|
|
|
> |
|
|
> |
|
|
<!-- label --> |
|
|
<!-- label --> |
|
|
<div>App Notifications</div> |
|
|
<div>App Notifications</div> |
|
@ -134,8 +117,8 @@ |
|
|
<!-- input --> |
|
|
<!-- input --> |
|
|
<input |
|
|
<input |
|
|
type="checkbox" |
|
|
type="checkbox" |
|
|
v-model="toggleNotifications" |
|
|
v-model="isSubscribed" |
|
|
name="toggleNotifications" |
|
|
name="toggleNotificationsInput" |
|
|
class="sr-only" |
|
|
class="sr-only" |
|
|
/> |
|
|
/> |
|
|
<!-- line --> |
|
|
<!-- line --> |
|
@ -145,11 +128,11 @@ |
|
|
class="dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition" |
|
|
class="dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition" |
|
|
></div> |
|
|
></div> |
|
|
</div> |
|
|
</div> |
|
|
</label> |
|
|
</div> |
|
|
<label v-else> |
|
|
<div v-else> |
|
|
Notification status may have changed. Revisit this page to see the |
|
|
Notification status may have changed. Revisit this page to see the |
|
|
latest setting. |
|
|
latest setting. |
|
|
</label> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<h3 class="text-sm uppercase font-semibold mb-3">Data</h3> |
|
|
<h3 class="text-sm uppercase font-semibold mb-3">Data</h3> |
|
@ -492,7 +475,8 @@ export default class AccountViewView extends Vue { |
|
|
derivationPath = ""; |
|
|
derivationPath = ""; |
|
|
givenName = ""; |
|
|
givenName = ""; |
|
|
isRegistered = false; |
|
|
isRegistered = false; |
|
|
notificationUnchanged = true; |
|
|
isSubscribed = false; |
|
|
|
|
|
notificationMaybeChanged = false; |
|
|
numAccounts = 0; |
|
|
numAccounts = 0; |
|
|
publicHex = ""; |
|
|
publicHex = ""; |
|
|
publicBase64 = ""; |
|
|
publicBase64 = ""; |
|
@ -514,15 +498,6 @@ export default class AccountViewView extends Vue { |
|
|
warnIfProdServer = false; |
|
|
warnIfProdServer = false; |
|
|
warnIfTestServer = false; |
|
|
warnIfTestServer = false; |
|
|
|
|
|
|
|
|
private isSubscribed = false; |
|
|
|
|
|
get toggleNotifications() { |
|
|
|
|
|
return this.isSubscribed; |
|
|
|
|
|
} |
|
|
|
|
|
set toggleNotifications(value) { |
|
|
|
|
|
this.isSubscribed = value; |
|
|
|
|
|
this.notificationUnchanged = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Async function executed when the component is created. |
|
|
* Async function executed when the component is created. |
|
|
* Initializes the component's state with values from the database, |
|
|
* Initializes the component's state with values from the database, |
|
@ -553,10 +528,9 @@ export default class AccountViewView extends Vue { |
|
|
try { |
|
|
try { |
|
|
const registration = await navigator.serviceWorker.ready; |
|
|
const registration = await navigator.serviceWorker.ready; |
|
|
this.subscription = await registration.pushManager.getSubscription(); |
|
|
this.subscription = await registration.pushManager.getSubscription(); |
|
|
this.toggleNotifications = !!this.subscription; |
|
|
this.isSubscribed = !!this.subscription; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error("Mount error:", error); |
|
|
console.error("Mount error:", error); |
|
|
this.toggleNotifications = false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -687,6 +661,31 @@ export default class AccountViewView extends Vue { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async showNotificationChoice() { |
|
|
|
|
|
if (!this.subscription) { |
|
|
|
|
|
this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: "modal", |
|
|
|
|
|
type: "notification-permission", |
|
|
|
|
|
title: "", // unused, only here to satisfy types |
|
|
|
|
|
text: "", // unused, only here to satisfy types |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: "modal", |
|
|
|
|
|
type: "notification-off", |
|
|
|
|
|
title: "", // unused, only here to satisfy types |
|
|
|
|
|
text: "", // unused, only here to satisfy types |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
this.notificationMaybeChanged = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Handles errors and updates the component's state accordingly. |
|
|
* Handles errors and updates the component's state accordingly. |
|
|
* @param {Error} err - The error object. |
|
|
* @param {Error} err - The error object. |
|
@ -725,12 +724,12 @@ export default class AccountViewView extends Vue { |
|
|
group: "alert", |
|
|
group: "alert", |
|
|
type: "danger", |
|
|
type: "danger", |
|
|
title: "Error Updating Contact Setting", |
|
|
title: "Error Updating Contact Setting", |
|
|
text: "Clear your cache and start over (after data backup).", |
|
|
text: "The setting may not have saved. Try again, maybe after restarting the app.", |
|
|
}, |
|
|
}, |
|
|
-1, |
|
|
-1, |
|
|
); |
|
|
); |
|
|
console.error( |
|
|
console.error( |
|
|
"Telling user to clear cache after contact setting update because:", |
|
|
"Telling user to try again after contact setting update because:", |
|
|
err, |
|
|
err, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
@ -748,12 +747,12 @@ export default class AccountViewView extends Vue { |
|
|
group: "alert", |
|
|
group: "alert", |
|
|
type: "danger", |
|
|
type: "danger", |
|
|
title: "Error Updating Prod Warning", |
|
|
title: "Error Updating Prod Warning", |
|
|
text: "Clear your cache and start over (after data backup).", |
|
|
text: "The setting may not have saved. Try again, maybe after restarting the app.", |
|
|
}, |
|
|
}, |
|
|
-1, |
|
|
-1, |
|
|
); |
|
|
); |
|
|
console.error( |
|
|
console.error( |
|
|
"Telling user to clear cache after contact setting update because:", |
|
|
"Telling user to try again after setting update because:", |
|
|
err, |
|
|
err, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
@ -771,12 +770,12 @@ export default class AccountViewView extends Vue { |
|
|
group: "alert", |
|
|
group: "alert", |
|
|
type: "danger", |
|
|
type: "danger", |
|
|
title: "Error Updating Test Warning", |
|
|
title: "Error Updating Test Warning", |
|
|
text: "Clear your cache and start over (after data backup).", |
|
|
text: "The setting may not have saved. Try again, maybe after restarting the app.", |
|
|
}, |
|
|
}, |
|
|
-1, |
|
|
-1, |
|
|
); |
|
|
); |
|
|
console.error( |
|
|
console.error( |
|
|
"Telling user to clear cache after contact setting update because:", |
|
|
"Telling user to try again after setting update because:", |
|
|
err, |
|
|
err, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|