feat: add delete button for local activities (single and bulk)

- Detail screen: Delete button (top-right, red) with confirmation alert;
  deletes SQLite row and original file via expo-file-system
- Feed screen: long-press card to enter select mode; checkbox + blue
  border on selected cards; bottom action bar with bulk Delete N button;
  header switches to show count + Cancel
- db/queries: deleteActivity (returns original_path) and deleteActivities
  (bulk, returns all original paths)
This commit is contained in:
Davide Scaini
2026-04-25 13:43:12 +02:00
parent c077fceba6
commit 1ac35c84e0
3 changed files with 197 additions and 21 deletions
+26
View File
@@ -110,6 +110,32 @@ export async function deleteRemoteActivities(
return result.changes;
}
export async function deleteActivity(
db: ReturnType<typeof useSQLiteContext>,
id: string,
): Promise<string | null> {
const row = db.getFirstSync<{ original_path: string | null }>(
'SELECT original_path FROM activities WHERE id = ?',
[id],
);
await db.runAsync('DELETE FROM activities WHERE id = ?', [id]);
return row?.original_path ?? null;
}
export async function deleteActivities(
db: ReturnType<typeof useSQLiteContext>,
ids: string[],
): Promise<Array<string | null>> {
if (ids.length === 0) return [];
const rows = db.getAllSync<{ original_path: string | null }>(
`SELECT original_path FROM activities WHERE id IN (${ids.map(() => '?').join(',')})`,
ids,
);
const placeholders = ids.map(() => '?').join(',');
await db.runAsync(`DELETE FROM activities WHERE id IN (${placeholders})`, ids);
return rows.map(r => r.original_path ?? null);
}
// ── Settings ───────────────────────────────────────────────────────────────
export async function getSetting(