add notification immediately after setting up subscription, and tweak messaging

This commit is contained in:
2024-01-03 21:27:13 -07:00
parent e9ad68f2a5
commit 1f05e81b05
5 changed files with 88 additions and 68 deletions

View File

@@ -291,6 +291,7 @@ interface VapidResponse {
import { DEFAULT_PUSH_SERVER } from "@/constants/app";
import { db } from "@/db/index";
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import { sendTestThroughPushServer } from "@/libs/util";
interface Notification {
group: string;
@@ -447,23 +448,34 @@ export default class App extends Vue {
.then((registration) => {
return registration.pushManager.getSubscription();
})
.then((subscription) => {
.then(async (subscription) => {
if (subscription) {
return this.sendSubscriptionToServer(subscription);
await this.$notify(
{
group: "alert",
type: "info",
title: "Notification Setup Underway",
text: "Setting up notifications for interesting activity, which takes about 10 seconds. If you don't see a final confirmation, check the 'Troubleshoot' page.",
},
-1,
);
this.sendSubscriptionToServer(subscription);
return subscription;
} else {
throw new Error("Subscription object is not available.");
}
})
.then(() => {
.then(async (subscription) => {
console.log(
"Subscription data sent to server and all finished successfully.",
);
await sendTestThroughPushServer(subscription, true);
this.$notify(
{
group: "alert",
type: "success",
title: "Notifications Turned On",
text: "Notifications are on. You should see one on your device; if not, see the 'Troubleshoot' page.",
text: "Notifications are on. You should see at least one on your device; if not, check the 'Troubleshoot' page.",
},
-1,
);