feat(watch): add workout deletion sync and optimize delete operations

This commit is contained in:
2026-08-12 13:52:23 +02:00
parent 2096489fd1
commit ca9259d5bd
6 changed files with 95 additions and 64 deletions
+6 -2
View File
@@ -253,7 +253,9 @@ export async function deleteSession(sessionId: string) {
export async function deleteSessionAndSync(sessionId: string) {
await deleteSession(sessionId);
await WatchConnectivity.sendWorkoutDeleted(sessionId);
WatchConnectivity.sendWorkoutDeleted(sessionId).catch((err) =>
console.warn("[ops] sync failed:", err)
);
}
export async function deleteWorkout(id: string) {
@@ -272,7 +274,9 @@ export async function deleteWorkout(id: string) {
export async function deleteWorkoutAndSync(id: string) {
await deleteWorkout(id);
await WatchConnectivity.sendWorkoutDeleted(id);
WatchConnectivity.sendWorkoutDeleted(id).catch((err) =>
console.warn("[ops] sync failed:", err)
);
}
// ─── Stats ───────────────────────────────────────────────────
@@ -52,7 +52,7 @@ export function HistoryScreen() {
style: "destructive",
onPress: async () => {
await deleteSessionAndSync(id);
await loadSessions();
setSessions((prev) => prev.filter((s) => s.id !== id));
},
},
]);
@@ -64,7 +64,7 @@ export function WorkoutListScreen() {
style: "destructive",
onPress: async () => {
await deleteWorkoutAndSync(id);
await loadWorkouts();
setWorkouts((prev) => prev.filter((w) => w.id !== id));
},
},
]);
+1
View File
@@ -9,6 +9,7 @@ WatchConnectivity = requireOptionalNativeModule("WatchConnectivity") ?? {
isReachable: async () => false,
sendWorkoutPlan: async () => ({ error: "WatchConnectivity native module not available" }),
sendWorkoutCompletion: async () => ({ error: "WatchConnectivity native module not available" }),
sendWorkoutDeleted: async () => ({ error: "WatchConnectivity native module not available" }),
pollEvents: async () => [],
getApplicationContext: async () => null,
updateApplicationContext: async () => {},