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:
Jose Olarte III
2026-03-31 15:57:22 +08:00
parent 2c8aa21fa5
commit 230dc52974
5 changed files with 83 additions and 65 deletions

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