feat(watch): add workout deletion sync and optimize delete operations
This commit is contained in:
@@ -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));
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -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 () => {},
|
||||
|
||||
Reference in New Issue
Block a user