Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): preserve saved environments across catalog recovery #8923

Closedglopyglerky(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/8923/headopened View on GitHub

Showing 2 changed files with 105 additions and 12 deletions.

x
0 of 2 viewed, 2 left
36 additions and 4 deletionsapps/mobile/src/connection/catalog-store.tsModified
View file
@@ -14,6 +14,7 @@
import { migrateLegacyConnectionCatalog } from "./migration";
​
export const CONNECTION_CATALOG_KEY = "t3code.connection-catalog.v1";
+export const CONNECTION_CATALOG_BACKUP_KEY = "t3code.connection-catalog.v1.backup";
export const LEGACY_CONNECTIONS_KEY = "t3code.connections";
​
function catalogError(operation: string, cause: unknown) {
@@ -74,12 +75,23 @@
);
if (legacyRaw !== null && legacyRaw.trim() !== "") {
const encoded = yield* encodeCatalog(catalog);
+ yield* setItem(CONNECTION_CATALOG_BACKUP_KEY, encoded);
yield* setItem(CONNECTION_CATALOG_KEY, encoded);
yield* deleteItem(LEGACY_CONNECTIONS_KEY);
return catalog;
});
​
+ const restoreBackup = Effect.fn("mobile.connectionStorage.restoreBackup")(function* () {
+ const backupRaw = yield* getItem(CONNECTION_CATALOG_BACKUP_KEY);
+ if (backupRaw === null || backupRaw.trim() === "") {
+ return Option.none<ConnectionCatalogDocumentType>();
+ }
+ const catalog = yield* decodeCatalog(backupRaw);
+ yield* setItem(CONNECTION_CATALOG_KEY, backupRaw);
+ return Option.some(catalog);
+ });
+​