Fix session replica behaviour (merge with session)
The harder-to-refactor parts are the places where exists/username/token are called within a React component. However, `resetAndRedirect` and `store` are already called from async contexts, so adding an `await` is simple. This thus merges the logic, keeping localStorage for the components to call, but making sure reset/store behaviour works correctly for the replica.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import Dexie from "dexie";
|
||||
import session from "./Session";
|
||||
import sessionReplica from "./SessionReplica";
|
||||
|
||||
// Uses Dexie.js
|
||||
// https://dexie.org/docs/API-Reference#quick-reference
|
||||
@@ -23,7 +22,7 @@ const createDatabase = (username) => {
|
||||
};
|
||||
|
||||
export const dbAsync = async () => {
|
||||
const username = await sessionReplica.username();
|
||||
const username = await session.usernameAsync();
|
||||
return createDatabase(username);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user