diff --git a/lib/utils/services-utils.js b/lib/utils/services-utils.js --- a/lib/utils/services-utils.js +++ b/lib/utils/services-utils.js @@ -9,6 +9,11 @@ // other Comm services. const usingCommServicesAccessToken = false; +// If this is true, then the app is able to support multiple keyservers. This +// requires the use of Tunnelbroker and the backup service to persist and sync +// the KeyserverStore. +const supportingMultipleKeyservers = false; + // If this is false, then the app no longer needs to rely on being connected to // an authoritative keyserver for things like DMs. const relyingOnAuthoritativeKeyserver = true; @@ -40,6 +45,7 @@ export { handleHTTPResponseError, usingCommServicesAccessToken, + supportingMultipleKeyservers, relyingOnAuthoritativeKeyserver, createHTTPAuthorizationHeader, createDefaultHTTPRequestHeaders, diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js --- a/native/data/sqlite-data-handler.js +++ b/native/data/sqlite-data-handler.js @@ -22,6 +22,7 @@ import { getMessageForException } from 'lib/utils/errors.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; +import { supportingMultipleKeyservers } from 'lib/utils/services-utils.js'; import { authoritativeKeyserverID } from '../authoritative-keyserver.js'; import { filesystemMediaCache } from '../media/media-cache.js'; @@ -116,6 +117,21 @@ ], ); + const recoverData = React.useCallback( + (source: RecoveryActionSource) => { + if (supportingMultipleKeyservers) { + invariant( + false, + 'recoverData in SQLiteDataHandler is not yet implemented when ' + + 'supportingMultipleKeyservers is enabled. It should recover ' + + 'from broken SQLite state by restoring from backup service', + ); + } + return recoverDataFromAuthoritativeKeyserver(source); + }, + [recoverDataFromAuthoritativeKeyserver], + ); + const callClearSensitiveData = React.useCallback( async (triggeredBy: string) => { await clearSensitiveData(); @@ -169,9 +185,7 @@ commCoreModule.terminate(); } } - await recoverDataFromAuthoritativeKeyserver( - recoveryActionSources.corruptedDatabaseDeletion, - ); + await recoverData(recoveryActionSources.corruptedDatabaseDeletion); })(); return; } @@ -232,9 +246,7 @@ '{no exception message}', ); } - await recoverDataFromAuthoritativeKeyserver( - recoveryActionSources.sqliteLoadFailure, - ); + await recoverData(recoveryActionSources.sqliteLoadFailure); } })(); }, [ @@ -245,7 +257,7 @@ rehydrateConcluded, staffCanSee, storeLoaded, - recoverDataFromAuthoritativeKeyserver, + recoverData, callClearSensitiveData, mediaCacheContext, ]);