refactor(notifications): use clearApiNotifications and scheduleApiNotifications

Update the refresh replacement flow for the renamed plugin APIs and remove
the obsolete clearPredictiveNotifications type augmentation.
This commit is contained in:
Jose Olarte III
2026-06-09 19:39:50 +08:00
parent a1f94300ad
commit cd32895281
3 changed files with 9 additions and 24 deletions

4
package-lock.json generated
View File

@@ -9923,8 +9923,8 @@
}
},
"node_modules/@timesafari/daily-notification-plugin": {
"version": "3.0.4",
"resolved": "git+https://gitea.anomalistdesign.com/trent_larson/daily-notification-plugin.git#6de300b7d4d50eae8feef09ba9f7238c210866f0",
"version": "4.0.1",
"resolved": "git+https://gitea.anomalistdesign.com/trent_larson/daily-notification-plugin.git#5703d2a1e3be39587ed4a0a81837fbdb591e9d89",
"license": "MIT",
"workspaces": [
"packages/*"

View File

@@ -707,17 +707,9 @@ export async function applyNotificationRefreshPayload(
logScheduleReplacement(timestamps.length);
// Plugin API still exposes clearPredictiveNotifications(); it clears API-managed notifications only.
const plugin = DailyNotification as unknown as {
clearPredictiveNotifications?: () => Promise<void>;
scheduleNotifications?: (options: {
timestamps: number[];
}) => Promise<void>;
};
if (typeof plugin.clearPredictiveNotifications !== "function") {
if (typeof DailyNotification.clearApiNotifications !== "function") {
logger.warn(
"[NativeNotificationService] API notification clear unavailable (plugin clearPredictiveNotifications missing); cannot replace schedule",
"[NativeNotificationService] API notification clear unavailable (plugin clearApiNotifications missing); cannot replace schedule",
);
logNotification(
"Schedule replacement aborted (API notification clear unavailable on plugin)",
@@ -726,20 +718,20 @@ export async function applyNotificationRefreshPayload(
}
logNotification("Clearing API notifications before refresh");
await plugin.clearPredictiveNotifications();
await DailyNotification.clearApiNotifications();
logNotification("Cleared API notifications");
if (typeof plugin.scheduleNotifications !== "function") {
if (typeof DailyNotification.scheduleApiNotifications !== "function") {
logger.warn(
"[NativeNotificationService] scheduleNotifications not available on plugin; cannot apply timestamps",
"[NativeNotificationService] scheduleApiNotifications not available on plugin; cannot apply timestamps",
);
logNotification(
"Schedule replacement aborted (scheduleNotifications unavailable)",
"Schedule replacement aborted (scheduleApiNotifications unavailable)",
);
return;
}
await plugin.scheduleNotifications({ timestamps });
await DailyNotification.scheduleApiNotifications({ timestamps });
logNotification(
`Schedule replacement applied (${timestamps.length} timestamp(s))`,
);

View File

@@ -1,7 +0,0 @@
import type {} from "@timesafari/daily-notification-plugin";
declare module "@timesafari/daily-notification-plugin" {
interface DailyNotificationPlugin {
clearPredictiveNotifications(): Promise<void>;
}
}