diff --git a/lib/shared/web-database.js b/lib/shared/web-database.js new file mode 100644 --- /dev/null +++ b/lib/shared/web-database.js @@ -0,0 +1,13 @@ +// @flow + +import { isStaff } from './staff-utils.js'; +import { isDev } from '../utils/dev-utils.js'; + +function canUseDatabaseOnWeb(userID: ?string): boolean { + if (!userID) { + return false; + } + return isDev || isStaff(userID); +} + +export { canUseDatabaseOnWeb }; diff --git a/web/redux/persist.js b/web/redux/persist.js --- a/web/redux/persist.js +++ b/web/redux/persist.js @@ -275,8 +275,7 @@ (state: KeyserverStore): PersistedKeyserverStore => { const keyserverInfos = {}; for (const key in state.keyserverInfos) { - const { connection, updatesCurrentAsOf, sessionID, ...rest } = - state.keyserverInfos[key]; + const { connection, sessionID, ...rest } = state.keyserverInfos[key]; keyserverInfos[key] = rest; } return { @@ -290,7 +289,6 @@ keyserverInfos[key] = { ...state.keyserverInfos[key], connection: { ...defaultConnectionInfo }, - updatesCurrentAsOf: 0, sessionID: null, }; } diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js --- a/web/redux/redux-setup.js +++ b/web/redux/redux-setup.js @@ -12,6 +12,7 @@ import { mostRecentlyReadThreadSelector } from 'lib/selectors/thread-selectors.js'; import { isLoggedIn } from 'lib/selectors/user-selectors.js'; import { invalidSessionDowngrade } from 'lib/shared/session-utils.js'; +import { canUseDatabaseOnWeb } from 'lib/shared/web-database.js'; import type { Shape } from 'lib/types/core.js'; import type { CryptoStore, @@ -128,9 +129,13 @@ const { userInfos, keyserverInfos, ...rest } = action.payload; const newKeyserverInfos = { ...state.keyserverStore.keyserverInfos }; for (const keyserverID in keyserverInfos) { + const newUpdatesCurrentAsOf = canUseDatabaseOnWeb(rest.currentUserInfo.id) + ? newKeyserverInfos[keyserverID].updatesCurrentAsOf + : keyserverInfos[keyserverID].updatesCurrentAsOf; newKeyserverInfos[keyserverID] = { ...newKeyserverInfos[keyserverID], ...keyserverInfos[keyserverID], + updatesCurrentAsOf: newUpdatesCurrentAsOf, }; } return validateState(oldState, {