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.
31 lines
875 B
TypeScript
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,
|
|
);
|
|
}
|
|
}
|