allow a test notification from the notification help screen

This commit is contained in:
2023-12-24 21:24:51 -07:00
parent 853eb3c623
commit 05c6ddda02
10 changed files with 183 additions and 45 deletions

View File

@@ -38,11 +38,29 @@ self.addEventListener("push", function (event) {
try {
let payload;
if (text) {
payload = JSON.parse(text);
try {
payload = JSON.parse(text);
} catch (e) {
// don't use payload since it is not JSON
}
}
// This should be a constant shared with the notification-test code. See TEST_PUSH_TITLE in HelpNotificationsView.vue
// 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";
let title = "Generic Notification";
let message = "Got some empty message.";
if (payload && payload.title == DIRECT_PUSH_TITLE) {
// skip any search logic and show the message directly
title = "Direct Message";
message = payload.message || "No details were provided.";
} else {
title =
payload && payload.title ? payload.title : "Unknown Notification";
message = await self.getNotificationCount();
}
const message = await self.getNotificationCount();
if (message) {
const title = payload && payload.title ? payload.title : "Message";
const options = {
body: message,
icon: payload ? payload.icon : "icon.png",