feat(saves): add one-click online data discovery and cache cleanup

Add user-initiated read-only discovery of local online client settings, copy selected files into the offline copy's staging directory before preview/import, clear the offline client's local cache for the imported account, and refresh save summaries after import.
This commit is contained in:
N0VAN0M4LY committed 2026-11-30 16:51:52 +08:00
1 parent f39d7b05c1
commit db84971823
8 files changed
+261 -25

No files matched your search

@@ -14,7 +14,13 @@ export type SaveTask = Location & (
| { readonly operation: 'editAccount'; readonly userId: string; readonly edits: AccountEdits }
| { readonly operation: 'edit'; readonly userId: string; readonly values: CurrencyEdits }
| { readonly operation: 'previewOfficial'; readonly paths: readonly string[]; readonly includeUsedVehicles: boolean }
| { readonly operation: 'importOfficial'; readonly paths: readonly string[]; readonly userId: string; readonly options: OfficialImportOptions }
| {
readonly operation: 'importOfficial';
readonly paths: readonly string[];
readonly userId: string;
readonly options: OfficialImportOptions;
readonly offlineClientCacheFolder?: string;
}
| { readonly operation: 'readResearch'; readonly userId: string; readonly branch?: ResearchBranch }
| { readonly operation: 'editResearch'; readonly userId: string; readonly branch: ResearchBranch; readonly action: ResearchOperation }
| { readonly operation: 'remove'; readonly userId: string }
@@ -28,7 +28,7 @@ function execute(task: SaveTask): SaveReply {
case 'previewOfficial':
return { ok: true, result: previewOfficialBackup(task, task.paths, task.includeUsedVehicles) };
case 'importOfficial':
return { ok: true, result: importOfficialBackup(task, task.userId, task.paths, task.options) };
return { ok: true, result: importOfficialBackup(task, task.userId, task.paths, task.options, task.offlineClientCacheFolder) };
case 'readResearch': {
const result = readSaveResearch(task, task.userId, task.branch);
return result ? { ok: true, result } : { ok: false, error: 'save_not_found' };