Skip to content

Commit

Permalink
Merge pull request #3988 from rtibbles/propagate_logout
Browse files Browse the repository at this point in the history
Propagate logout to all open tabs
  • Loading branch information
bjester authored Mar 15, 2023
2 parents 59cc6d2 + 265c248 commit db36b2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 8 additions & 0 deletions contentcuration/contentcuration/frontend/shared/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,18 @@ function runElection() {
};
}

function applyResourceListener(change) {
const resource = INDEXEDDB_RESOURCES[change.table];
if (resource && resource.listeners && resource.listeners[change.type]) {
resource.listeners[change.type](change);
}
}

export async function initializeDB() {
try {
setupSchema();
await db.open();
db.on('changes', changes => changes.map(applyResourceListener));
await runElection();
} catch (e) {
Sentry.captureException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ function isSyncableChange(change) {
);
}

function applyResourceListener(change) {
const resource = INDEXEDDB_RESOURCES[change.table];
if (resource && resource.listeners && resource.listeners[change.type]) {
resource.listeners[change.type](change);
}
}

/**
* Reduces a change to only the fields that are needed for sending it to the backend
*
Expand Down Expand Up @@ -338,7 +331,6 @@ if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined') {
}

async function handleChanges(changes) {
changes.map(applyResourceListener);
const syncableChanges = changes.filter(isSyncableChange);
// Here we are handling changes triggered by Dexie Observable
// this is listening to all of our IndexedDB tables, both for resources
Expand Down

0 comments on commit db36b2f

Please sign in to comment.