WIP: new-activity notification #231
@@ -709,29 +709,28 @@ export async function applyNotificationRefreshPayload(
|
||||
logScheduleReplacement(timestamps.length);
|
||||
|
||||
const plugin = DailyNotification as unknown as {
|
||||
clearAllNotifications?: () => Promise<void>;
|
||||
clearPredictiveNotifications?: () => Promise<void>;
|
||||
scheduleNotifications?: (options: {
|
||||
timestamps: number[];
|
||||
}) => Promise<void>;
|
||||
cancelAllNotifications?: () => Promise<void>;
|
||||
};
|
||||
|
||||
if (typeof plugin.clearAllNotifications === "function") {
|
||||
logNotificationClearing("clearAllNotifications");
|
||||
await plugin.clearAllNotifications();
|
||||
} else if (typeof plugin.cancelAllNotifications === "function") {
|
||||
logNotificationClearing("cancelAllNotifications");
|
||||
await plugin.cancelAllNotifications();
|
||||
} else {
|
||||
if (typeof plugin.clearPredictiveNotifications !== "function") {
|
||||
logger.warn(
|
||||
"[NativeNotificationService] No clearAllNotifications/cancelAllNotifications on plugin; cannot replace schedule",
|
||||
"[NativeNotificationService] No clearPredictiveNotifications on plugin; cannot replace schedule",
|
||||
);
|
||||
logNotification(
|
||||
"Schedule replacement aborted (clear method unavailable on plugin)",
|
||||
"Schedule replacement aborted (clearPredictiveNotifications unavailable on plugin)",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(
|
||||
"[Notifications] Clearing predictive notifications before refresh",
|
||||
);
|
||||
logNotificationClearing("clearPredictiveNotifications");
|
||||
await plugin.clearPredictiveNotifications();
|
||||
|
||||
if (typeof plugin.scheduleNotifications !== "function") {
|
||||
logger.warn(
|
||||
"[NativeNotificationService] scheduleNotifications not available on plugin; cannot apply timestamps",
|
||||
|
||||
7
src/types/daily-notification-plugin.d.ts
vendored
Normal file
7
src/types/daily-notification-plugin.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type {} from "@timesafari/daily-notification-plugin";
|
||||
|
||||
declare module "@timesafari/daily-notification-plugin" {
|
||||
interface DailyNotificationPlugin {
|
||||
clearPredictiveNotifications(): Promise<void>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user