diff --git a/lib/actions/aux-user-actions.js b/lib/actions/aux-user-actions.js --- a/lib/actions/aux-user-actions.js +++ b/lib/actions/aux-user-actions.js @@ -10,10 +10,13 @@ const removePeerUsersActionType = 'REMOVE_PEER_USERS'; +const setMissingDeviceListsActionType = 'SET_MISSING_DEVICE_LISTS'; + export { setAuxUserFIDsActionType, addAuxUserFIDsActionType, clearAuxUserFIDsActionType, setPeerDeviceListsActionType, removePeerUsersActionType, + setMissingDeviceListsActionType, }; diff --git a/lib/reducers/aux-user-reducer.js b/lib/reducers/aux-user-reducer.js --- a/lib/reducers/aux-user-reducer.js +++ b/lib/reducers/aux-user-reducer.js @@ -1,6 +1,7 @@ // @flow import { + setMissingDeviceListsActionType, setAuxUserFIDsActionType, addAuxUserFIDsActionType, clearAuxUserFIDsActionType, @@ -136,12 +137,15 @@ } else if (action.type === setPeerDeviceListsActionType) { const replaceOperations: ReplaceAuxUserInfoOperation[] = []; for (const userID in action.payload.deviceLists) { + const { accountMissingStatus, ...rest } = + state.auxUserInfos[userID] ?? {}; + replaceOperations.push({ type: 'replace_aux_user_info', payload: { id: userID, auxUserInfo: { - ...state.auxUserInfos[userID], + ...rest, fid: state.auxUserInfos[userID]?.fid ?? null, deviceList: action.payload.deviceLists[userID], devicesPlatformDetails: action.payload.usersPlatformDetails[userID], @@ -149,6 +153,32 @@ }, }); } + return { + auxUserStore: processStoreOps(state, replaceOperations), + auxUserStoreOperations: replaceOperations, + }; + } else if (action.type === setMissingDeviceListsActionType) { + const replaceOperations: ReplaceAuxUserInfoOperation[] = []; + + const { time, userIDs } = action.payload.usersMissingFromIdentity; + for (const userID of userIDs) { + replaceOperations.push({ + type: 'replace_aux_user_info', + payload: { + id: userID, + auxUserInfo: { + ...state.auxUserInfos[userID], + accountMissingStatus: { + missingSince: + state.auxUserInfos[userID]?.accountMissingStatus + ?.missingSince ?? time, + lastChecked: time, + }, + }, + }, + }); + } + return { auxUserStore: processStoreOps(state, replaceOperations), auxUserStoreOperations: replaceOperations, diff --git a/lib/types/aux-user-types.js b/lib/types/aux-user-types.js --- a/lib/types/aux-user-types.js +++ b/lib/types/aux-user-types.js @@ -41,3 +41,10 @@ +[userID: string]: { +[deviceID: string]: IdentityPlatformDetails }, }, }; + +export type SetMissingDeviceListsPayload = { + +usersMissingFromIdentity: { + +userIDs: $ReadOnlyArray, + +time: number, + }, +}; diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -24,6 +24,7 @@ AddAuxUserFIDsPayload, RemovePeerUsersPayload, SetPeerDeviceListsPayload, + SetMissingDeviceListsPayload, } from './aux-user-types.js'; import type { UpdateUserAvatarRequest, @@ -1650,6 +1651,10 @@ +type: 'PROCESS_HOLDERS_SUCCESS', +payload: ProcessHoldersFinishedPayload, +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_MISSING_DEVICE_LISTS', + +payload: SetMissingDeviceListsPayload, }, }>;