feat(notifications): sync starred plans to native plugin on star/unstar
Add syncStarredPlansToNativePlugin() and call it from AccountViewView (schedule + initializeState) and ProjectViewView.toggleStar when New Activity is enabled so Android prefetch uses the current starred list. Update notification-from-api-call.md with the helper and file references.
This commit is contained in:
30
src/services/notifications/syncStarredPlansToNativePlugin.ts
Normal file
30
src/services/notifications/syncStarredPlansToNativePlugin.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
|
||||
import { DailyNotification } from "@/plugins/DailyNotificationPlugin";
|
||||
import { logger } from "@/utils/logger";
|
||||
|
||||
/**
|
||||
* Pushes starred plan handle IDs to the native Daily Notification plugin so
|
||||
* Android TimeSafariNativeFetcher uses the current list for prefetch
|
||||
* (plansLastUpdatedBetween planIds).
|
||||
*
|
||||
* No-op on web. Ignores UNIMPLEMENTED when the plugin omits the method on some builds.
|
||||
*/
|
||||
export async function syncStarredPlansToNativePlugin(
|
||||
planIds: string[],
|
||||
): Promise<void> {
|
||||
if (!Capacitor.isNativePlatform()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await DailyNotification.updateStarredPlans({ planIds });
|
||||
} catch (e: unknown) {
|
||||
if ((e as { code?: string })?.code === "UNIMPLEMENTED") {
|
||||
return;
|
||||
}
|
||||
logger.warn(
|
||||
"[syncStarredPlansToNativePlugin] updateStarredPlans failed",
|
||||
e,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user