forked from trent_larson/crowd-funder-for-time-pwa
allow a test notification from the notification help screen
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -503,7 +503,6 @@ async function getNotificationCount() {
|
||||
lastNotifiedClaimId = settings["lastNotifiedClaimId"];
|
||||
}
|
||||
const activeDid = settings["activeDid"];
|
||||
console.log("safari-not getNotificationsCount last", lastNotifiedClaimId);
|
||||
accounts = await fetchAllAccounts();
|
||||
let activeAccount = null;
|
||||
for (let i = 0; i < accounts.length; i++) {
|
||||
@@ -532,7 +531,6 @@ async function getNotificationCount() {
|
||||
headers["Authorization"] = "Bearer " + (await accessToken(identifier));
|
||||
}
|
||||
|
||||
console.log("safari-not getNotificationsCount fetch", headers);
|
||||
const response = await fetch(
|
||||
settings["apiServer"] + "/api/v2/report/claims",
|
||||
{
|
||||
@@ -540,10 +538,8 @@ async function getNotificationCount() {
|
||||
headers: headers,
|
||||
},
|
||||
);
|
||||
console.log("safari-not getNotificationsCount json", response);
|
||||
if (response.status == 200) {
|
||||
const json = await response.json();
|
||||
console.log("safari-not getNotificationsCount json", json);
|
||||
const claims = json["data"];
|
||||
let newClaims = 0;
|
||||
for (let i = 0; i < claims.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user