fix(notifications): use clearPredictiveNotifications on refresh
Avoid cancelAllNotifications during schedule replacement so Daily Reminder schedules are not cleared.
This commit is contained in:
@@ -709,29 +709,28 @@ export async function applyNotificationRefreshPayload(
|
|||||||
logScheduleReplacement(timestamps.length);
|
logScheduleReplacement(timestamps.length);
|
||||||
|
|
||||||
const plugin = DailyNotification as unknown as {
|
const plugin = DailyNotification as unknown as {
|
||||||
clearAllNotifications?: () => Promise<void>;
|
clearPredictiveNotifications?: () => Promise<void>;
|
||||||
scheduleNotifications?: (options: {
|
scheduleNotifications?: (options: {
|
||||||
timestamps: number[];
|
timestamps: number[];
|
||||||
}) => Promise<void>;
|
}) => Promise<void>;
|
||||||
cancelAllNotifications?: () => Promise<void>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof plugin.clearAllNotifications === "function") {
|
if (typeof plugin.clearPredictiveNotifications !== "function") {
|
||||||
logNotificationClearing("clearAllNotifications");
|
|
||||||
await plugin.clearAllNotifications();
|
|
||||||
} else if (typeof plugin.cancelAllNotifications === "function") {
|
|
||||||
logNotificationClearing("cancelAllNotifications");
|
|
||||||
await plugin.cancelAllNotifications();
|
|
||||||
} else {
|
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"[NativeNotificationService] No clearAllNotifications/cancelAllNotifications on plugin; cannot replace schedule",
|
"[NativeNotificationService] No clearPredictiveNotifications on plugin; cannot replace schedule",
|
||||||
);
|
);
|
||||||
logNotification(
|
logNotification(
|
||||||
"Schedule replacement aborted (clear method unavailable on plugin)",
|
"Schedule replacement aborted (clearPredictiveNotifications unavailable on plugin)",
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"[Notifications] Clearing predictive notifications before refresh",
|
||||||
|
);
|
||||||
|
logNotificationClearing("clearPredictiveNotifications");
|
||||||
|
await plugin.clearPredictiveNotifications();
|
||||||
|
|
||||||
if (typeof plugin.scheduleNotifications !== "function") {
|
if (typeof plugin.scheduleNotifications !== "function") {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"[NativeNotificationService] scheduleNotifications not available on plugin; cannot apply timestamps",
|
"[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