Files
crowd-funder-for-time-pwa/src/services/notifications/syncStarredPlansToNativePlugin.ts
Jose Olarte III 230dc52974 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.
2026-03-31 15:57:22 +08:00

31 lines
875 B
TypeScript

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,
);
}
}