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 @@ -223,10 +223,13 @@ auxUserStoreOperations: removeUsersOps, }; } else if (action.type === removePeerUsersActionType) { + const userIDs = action.payload.updatesResult.newUpdates.map( + update => update.deletedUserID, + ); const removeUsersOps: RemoveAuxUserInfosOperation[] = [ { type: 'remove_aux_user_infos', - payload: { ids: action.payload.userIDs }, + payload: { ids: userIDs }, }, ]; diff --git a/lib/reducers/thread-reducer.js b/lib/reducers/thread-reducer.js --- a/lib/reducers/thread-reducer.js +++ b/lib/reducers/thread-reducer.js @@ -4,6 +4,7 @@ setThreadUnreadStatusActionTypes, updateActivityActionTypes, } from '../actions/activity-actions.js'; +import { removePeerUsersActionType } from '../actions/aux-user-actions.js'; import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js'; import { saveMessagesActionType } from '../actions/message-actions.js'; import { legacySiweAuthActionTypes } from '../actions/siwe-actions.js'; @@ -262,7 +263,8 @@ action.type === processUpdatesActionType || action.type === newThreadActionTypes.success || action.type === modifyCommunityRoleActionTypes.success || - action.type === deleteCommunityRoleActionTypes.success + action.type === deleteCommunityRoleActionTypes.success || + action.type === removePeerUsersActionType ) { const { newUpdates } = action.payload.updatesResult; if (newUpdates.length === 0) { diff --git a/lib/reducers/user-reducer.js b/lib/reducers/user-reducer.js --- a/lib/reducers/user-reducer.js +++ b/lib/reducers/user-reducer.js @@ -578,10 +578,13 @@ userStoreOps, ]; } else if (action.type === removePeerUsersActionType) { + const userIDs = action.payload.updatesResult.newUpdates.map( + update => update.deletedUserID, + ); const userStoreOps: UserStoreOperation[] = [ { type: 'remove_users', - payload: { ids: action.payload.userIDs }, + payload: { ids: userIDs }, }, ]; diff --git a/lib/tunnelbroker/use-peer-to-peer-message-handler.js b/lib/tunnelbroker/use-peer-to-peer-message-handler.js --- a/lib/tunnelbroker/use-peer-to-peer-message-handler.js +++ b/lib/tunnelbroker/use-peer-to-peer-message-handler.js @@ -3,6 +3,7 @@ import invariant from 'invariant'; import _isEqual from 'lodash/fp/isEqual.js'; import * as React from 'react'; +import uuid from 'uuid'; import { useResendPeerToPeerMessages } from './use-resend-peer-to-peer-messages.js'; import { removePeerUsersActionType } from '../actions/aux-user-actions.js'; @@ -36,6 +37,8 @@ userActionP2PMessageValidator, type UserActionP2PMessage, } from '../types/tunnelbroker/user-actions-peer-to-peer-message-types.js'; +import { updateTypes } from '../types/update-types-enum.js'; +import type { AccountDeletionUpdateInfo } from '../types/update-types.js'; import { getConfig } from '../utils/config.js'; import { getContentSigningKey } from '../utils/crypto-utils.js'; import { getMessageForException } from '../utils/errors.js'; @@ -147,9 +150,15 @@ primaryDeviceRequestedLogOut(), ); } else { + const deleteUserUpdate: AccountDeletionUpdateInfo = { + time: Date.now(), + id: uuid.v4(), + deletedUserID: senderInfo.userID, + type: updateTypes.DELETE_ACCOUNT, + }; dispatch({ type: removePeerUsersActionType, - payload: { userIDs: [senderInfo.userID] }, + payload: { updatesResult: { newUpdates: [deleteUserUpdate] } }, }); await sqliteAPI.removeInboundP2PMessages([messageID]); } 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 @@ -6,6 +6,7 @@ UsersRawDeviceLists, IdentityPlatformDetails, } from './identity-service-types.js'; +import type { AccountDeletionUpdateInfo } from './update-types.js'; type AccountMissingFromIdentityStatus = { +missingSince: number, @@ -33,7 +34,9 @@ +farcasterUsers: $ReadOnlyArray, }; -export type RemovePeerUsersPayload = { +userIDs: $ReadOnlyArray }; +export type RemovePeerUsersPayload = { + +updatesResult: { +newUpdates: $ReadOnlyArray }, +}; export type SetPeerDeviceListsPayload = { +deviceLists: UsersRawDeviceLists,