diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js --- a/lib/reducers/master-reducer.js +++ b/lib/reducers/master-reducer.js @@ -36,7 +36,6 @@ } from '../types/socket-types.js'; import type { StoreOperations } from '../types/store-ops-types.js'; import { isDev } from '../utils/dev-utils.js'; -import { ashoatKeyserverID } from '../utils/validation-utils.js'; export default function baseReducer>( state: T, @@ -79,39 +78,43 @@ let keyserverStore = reduceKeyserverStore(state.keyserverStore, action); if ( - keyserverStore.keyserverInfos[ashoatKeyserverID].connection.status !== - 'connected' && action.type !== incrementalStateSyncActionType && action.type !== fullStateSyncActionType && action.type !== registerActionTypes.success && action.type !== logInActionTypes.success && action.type !== siweAuthActionTypes.success ) { - if ( - messageStore.currentAsOf[ashoatKeyserverID] !== - state.messageStore.currentAsOf[ashoatKeyserverID] - ) { - messageStore = { - ...messageStore, - currentAsOf: { - ...messageStore.currentAsOf, - [ashoatKeyserverID]: - state.messageStore.currentAsOf[ashoatKeyserverID], - }, - }; - } - if ( - keyserverStore.keyserverInfos[ashoatKeyserverID].updatesCurrentAsOf !== - state.keyserverStore.keyserverInfos[ashoatKeyserverID].updatesCurrentAsOf - ) { - const keyserverInfos = { ...keyserverStore.keyserverInfos }; - keyserverInfos[ashoatKeyserverID] = { - ...keyserverInfos[ashoatKeyserverID], - updatesCurrentAsOf: - state.keyserverStore.keyserverInfos[ashoatKeyserverID] - .updatesCurrentAsOf, - }; - keyserverStore = { ...keyserverStore, keyserverInfos }; + for (const keyserverID in keyserverStore.keyserverInfos) { + if ( + keyserverStore.keyserverInfos[keyserverID].connection.status === + 'connected' + ) { + continue; + } + if ( + messageStore.currentAsOf[keyserverID] !== + state.messageStore.currentAsOf[keyserverID] + ) { + messageStore = { + ...messageStore, + currentAsOf: { + ...messageStore.currentAsOf, + [keyserverID]: state.messageStore.currentAsOf[keyserverID], + }, + }; + } + if ( + keyserverStore.keyserverInfos[keyserverID].updatesCurrentAsOf !== + state.keyserverStore.keyserverInfos[keyserverID].updatesCurrentAsOf + ) { + const keyserverInfos = { ...keyserverStore.keyserverInfos }; + keyserverInfos[keyserverID] = { + ...keyserverInfos[keyserverID], + updatesCurrentAsOf: + state.keyserverStore.keyserverInfos[keyserverID].updatesCurrentAsOf, + }; + keyserverStore = { ...keyserverStore, keyserverInfos }; + } } }