Android home-screen widget: top-3 next actions (4x2 'Next up' card) — tap the priority ring to complete via the offline queue, rows deep-link to Clarify, + opens capture; redraws on every store change plus a 30-min self-refresh
Some checks failed
Build & Release APK / build (push) Failing after 24s
Some checks failed
Build & Release APK / build (push) Failing after 24s
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
19
app/src/widget/widget-task-handler.tsx
Normal file
19
app/src/widget/widget-task-handler.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
// Headless entry point for widget events. When the app's JS context is
|
||||
// alive this shares the in-memory store; when launched cold, hydrate() loads
|
||||
// AsyncStorage — so completing from the widget goes through the exact same
|
||||
// local-first mutation path (instant local write, op queued, synced later).
|
||||
import type { WidgetTaskHandlerProps } from "react-native-android-widget";
|
||||
import { hydrate, updateTask } from "../lib/store";
|
||||
import { renderNextUpWidget } from "./render";
|
||||
|
||||
export async function widgetTaskHandler(props: WidgetTaskHandlerProps) {
|
||||
if (props.widgetAction === "WIDGET_DELETED") return;
|
||||
await hydrate();
|
||||
if (props.widgetAction === "WIDGET_CLICK") {
|
||||
// OPEN_APP / OPEN_URI are handled natively; only completion reaches JS.
|
||||
if (props.clickAction !== "COMPLETE_TASK") return;
|
||||
const taskId = props.clickActionData?.taskId;
|
||||
if (typeof taskId === "string") updateTask(taskId, { status: "done" });
|
||||
}
|
||||
props.renderWidget(renderNextUpWidget());
|
||||
}
|
||||
Reference in New Issue
Block a user