Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failed dApp connector API calls after service worker going to sleep #3728

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export async function raii<T>(
)
).join('\n');
// eslint-disable-next-line no-console
console.error('rolling back Lovefield query for\n' + uniqueTableNames + ' with error ' + JSON.stringify(e));
console.error('rolling back Lovefield query for\n' + uniqueTableNames + ' with error ' + e.message);
await tx.rollback();
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@ import { migrateNoRefresh } from '../../../../app/api/common/migration';
import LocalStorageApi from '../../../../app/api/localStorage/index';
import type { lf$Database, } from 'lovefield';

let dbCache = null;
let loadDbPromiseCache = null;
let migratePromiseCache = null;

export async function getDb(): Promise<lf$Database> {
const localStorageApi = new LocalStorageApi();

if (!dbCache) {
dbCache = await loadLovefieldDB(schema.DataStoreType.INDEXED_DB);
if (!loadDbPromiseCache) {
loadDbPromiseCache = loadLovefieldDB(schema.DataStoreType.INDEXED_DB);
}

const db = await loadDbPromiseCache;

if (!migratePromiseCache) {
migratePromiseCache = migrateNoRefresh({
localStorageApi,
persistentDb: dbCache,
persistentDb: db,
currVersion: environment.getVersion(),
});
}
await migratePromiseCache;

return dbCache;
return db;
}
Loading