{
+ await db.open();
+ const todayKey = new Date().toDateString();
+ // only keep one day's worth of logs
+ const previous = await db.logs.get(todayKey);
+ if (!previous) {
+ // when this is today's first log, clear out everything previous
+ await db.logs.clear();
+ }
+ const fullMessage = (previous && previous.message) || "";
+ await db.logs.update(todayKey, { message: fullMessage + "\n" + message });
+}
diff --git a/src/libs/util.ts b/src/libs/util.ts
index 07a3b15..52b7e5c 100644
--- a/src/libs/util.ts
+++ b/src/libs/util.ts
@@ -374,8 +374,8 @@ export const sendTestThroughPushServer = async (
pushUrl = settings.webPushServer;
}
- // This is a special value that tells the service worker to send a direct notification to the device, skipping filters.
// This is shared with the service worker and should be a constant. Look for the same name in additional-scripts.js
+ // This is a special value that tells the service worker to send a direct notification to the device, skipping filters.
// Use something other than "Daily Update" https://gitea.anomalistdesign.com/trent_larson/py-push-server/src/commit/3c0e196c11bc98060ec5934e99e7dbd591b5da4d/app.py#L213
const DIRECT_PUSH_TITLE = "DIRECT_NOTIFICATION";
diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue
index dee3426..fe1bb67 100644
--- a/src/views/AccountViewView.vue
+++ b/src/views/AccountViewView.vue
@@ -595,6 +595,7 @@
Partner Server URL
+
{{ DEFAULT_PARTNER_API_SERVER }}
@@ -830,7 +831,7 @@ export default class AccountViewView extends Vue {
/**
* Beware! I've seen where this "ready" never resolves.
*/
- const registration = await navigator.serviceWorker.ready;
+ const registration = await navigator.serviceWorker?.ready;
this.subscription = await registration.pushManager.getSubscription();
this.isSubscribed = !!this.subscription;
// console.log("Got to the end of 'mounted' call in AccountViewView.");
diff --git a/src/views/HelpNotificationsView.vue b/src/views/HelpNotificationsView.vue
index 313e88b..6e913a1 100644
--- a/src/views/HelpNotificationsView.vue
+++ b/src/views/HelpNotificationsView.vue
@@ -305,8 +305,8 @@ export default class HelpNotificationsView extends Vue {
async mounted() {
try {
- const registration = await navigator.serviceWorker.ready;
- const fullSub = await registration.pushManager.getSubscription();
+ const registration = await navigator.serviceWorker?.ready;
+ const fullSub = await registration?.pushManager.getSubscription();
this.subscriptionJSON = fullSub?.toJSON();
} catch (error) {
console.error("Mount error:", error);
@@ -366,7 +366,7 @@ export default class HelpNotificationsView extends Vue {
showTestNotification() {
const TEST_NOTIFICATION_TITLE = "It Worked";
- navigator.serviceWorker.ready
+ navigator.serviceWorker?.ready
.then((registration) => {
return registration.showNotification(TEST_NOTIFICATION_TITLE, {
body: "This is your test notification.",
diff --git a/sw_scripts/additional-scripts.js b/sw_scripts/additional-scripts.js
index ebdff59..c0cce22 100644
--- a/sw_scripts/additional-scripts.js
+++ b/sw_scripts/additional-scripts.js
@@ -63,9 +63,9 @@ self.addEventListener("push", function (event) {
// See https://gitea.anomalistdesign.com/trent_larson/py-push-server/src/commit/c1ed026662e754348a5f91542680bd4f57e5b81e/app.py#L217
const DAILY_UPDATE_TITLE = "DAILY_CHECK";
- // This is a special value that tells the service worker to send a direct notification to the device, skipping filters.
// This is shared with the notification-test code and should be a constant. Look for the same name in HelpNotificationsView.vue
- // Make sure it is something other than the DAILY_UPDATE_TITLE.
+ // This is a special value that tells the service worker to send a direct notification to the device, skipping filters.
+ // Make sure it is something different from the DAILY_UPDATE_TITLE.
const DIRECT_PUSH_TITLE = "DIRECT_NOTIFICATION";
let title;
@@ -133,7 +133,8 @@ self.addEventListener("notificationclick", (event) => {
// This is invoked when the user chooses this as a share_target, mapped to share-target in the manifest.
self.addEventListener("fetch", (event) => {
- logConsoleAndDb("Service worker got fetch event.", event);
+ // Skipping this because we get so many of them, at startup and other times.
+ //logConsoleAndDb("Service worker got fetch event.", event);
// Bypass any regular requests not related to Web Share Target
// and also requests that are not exactly to the timesafari.app