From eee6344c1b7ceb7fd6ff00bab26a49c877430a8a Mon Sep 17 00:00:00 2001 From: Bryan Roscoe Date: Thu, 8 Oct 2026 16:16:17 -0500 Subject: [PATCH] Bind mobile file operations to the active connection generation --- v2/mobile/src/lib/appFiles.ts | 12 ++++ v2/mobile/src/screens/Files.svelte | 79 ++++++++++++++++-------- v2/mobile/tests/file-connection.test.mjs | 27 ++++++++ v2/mobile/tests/files.test.mjs | 32 ++++++++++ 4 files changed, 124 insertions(+), 26 deletions(-) create mode 100644 v2/mobile/tests/file-connection.test.mjs diff --git a/v2/mobile/src/lib/appFiles.ts b/v2/mobile/src/lib/appFiles.ts index 61855028..d959e19a 100644 --- a/v2/mobile/src/lib/appFiles.ts +++ b/v2/mobile/src/lib/appFiles.ts @@ -6,6 +6,18 @@ import type { FindResult } from "./types"; // Single source with desktop's Files tab: read the catalog, don't copy it. import catalog from "../../../src/lib/app-files-catalog.json"; +export interface FileConnection { + serial: string; + generation: number; +} + +export function fileConnectionMatches( + target: FileConnection, + current: { serial: string | null; generation: number; isConnected: boolean }, +): boolean { + return current.isConnected && target.serial === current.serial && target.generation === current.generation; +} + export interface AppFilesEntry { id: string; package: string; diff --git a/v2/mobile/src/screens/Files.svelte b/v2/mobile/src/screens/Files.svelte index 1773b25d..0b48bb51 100644 --- a/v2/mobile/src/screens/Files.svelte +++ b/v2/mobile/src/screens/Files.svelte @@ -1,5 +1,5 @@