diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -506,10 +506,16 @@ }; })(); + const connectionPromise = (async () => ({ + ...defaultConnectionInfo(viewer.platform ?? 'web', viewer.timeZone), + actualizedCalendarQuery: await calendarQueryPromise, + }))(); + const keyserverStorePromise = (async () => { - const { sessionID, updatesCurrentAsOf } = await promiseAll({ + const { sessionID, updatesCurrentAsOf, connection } = await promiseAll({ sessionID: sessionIDPromise, updatesCurrentAsOf: currentAsOfPromise, + connection: connectionPromise, }); return { @@ -519,6 +525,7 @@ sessionID, updatesCurrentAsOf, urlPrefix, + connection, }, }, }; @@ -595,10 +602,7 @@ communityPickerStore: { chat: null, calendar: null }, windowDimensions: { width: 0, height: 0 }, notifPermissionAlertInfo: defaultNotifPermissionAlertInfo, - connection: (async () => ({ - ...defaultConnectionInfo(viewer.platform ?? 'web', viewer.timeZone), - actualizedCalendarQuery: await calendarQueryPromise, - }))(), + connection: connectionPromise, watchedThreadIDs: [], lifecycleState: 'active', enabledApps: defaultWebEnabledApps, diff --git a/lib/reducers/keyserver-reducer.js b/lib/reducers/keyserver-reducer.js --- a/lib/reducers/keyserver-reducer.js +++ b/lib/reducers/keyserver-reducer.js @@ -1,5 +1,6 @@ // @flow +import reduceConnectionInfo from './connection-reducer.js'; import reduceUpdatesCurrentAsOf from './updates-reducer.js'; import { siweAuthActionTypes } from '../actions/siwe-actions.js'; import { @@ -32,7 +33,7 @@ keyserverInfos[key] = { ...keyserverInfos[key], cookie: null }; } - return { + state = { ...state, keyserverInfos: { ...keyserverInfos, @@ -44,7 +45,7 @@ }; } else if (action.type === setNewSessionActionType) { if (action.payload.sessionChange.cookie !== undefined) { - return { + state = { ...state, keyserverInfos: { ...state.keyserverInfos, @@ -66,7 +67,7 @@ state.keyserverInfos[ashoatKeyserverID].updatesCurrentAsOf, action, ); - return { + state = { ...state, keyserverInfos: { ...state.keyserverInfos, @@ -77,7 +78,7 @@ }, }; } else if (action.type === setURLPrefix) { - return { + state = { ...state, keyserverInfos: { ...state.keyserverInfos, @@ -89,5 +90,20 @@ }; } + const connection = reduceConnectionInfo( + state.keyserverInfos[ashoatKeyserverID].connection, + action, + ); + state = { + ...state, + keyserverInfos: { + ...state.keyserverInfos, + [ashoatKeyserverID]: { + ...state.keyserverInfos[ashoatKeyserverID], + connection, + }, + }, + }; + return state; } diff --git a/lib/types/keyserver-types.js b/lib/types/keyserver-types.js --- a/lib/types/keyserver-types.js +++ b/lib/types/keyserver-types.js @@ -2,6 +2,8 @@ import t, { type TInterface } from 'tcomb'; +import { connectionInfoValidator } from './socket-types.js'; +import type { ConnectionInfo } from './socket-types.js'; import { tShape } from '../utils/validation-utils.js'; // Once we start using the cookie field on web, @@ -12,6 +14,7 @@ +sessionID?: ?string, +updatesCurrentAsOf: number, // millisecond timestamp +urlPrefix: string, + +connection: ConnectionInfo, }; export type KeyserverStore = { @@ -24,6 +27,7 @@ sessionID: t.maybe(t.String), updatesCurrentAsOf: t.Number, urlPrefix: t.String, + connection: connectionInfoValidator, }); export const keyserverStoreValidator: TInterface<KeyserverStore> = diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -125,6 +125,7 @@ [ashoatKeyserverID]: { updatesCurrentAsOf: 0, urlPrefix: defaultURLPrefix, + connection: defaultConnectionInfo(Platform.OS), }, }, },