diff --git a/lib/hooks/ops-hooks.js b/lib/hooks/ops-hooks.js --- a/lib/hooks/ops-hooks.js +++ b/lib/hooks/ops-hooks.js @@ -2,20 +2,20 @@ import * as React from 'react'; -import type { MessageID } from '../types/db-ops-types.js'; +import type { MessageData } from '../types/db-ops-types.js'; import type { SuperAction } from '../types/redux-types.js'; import { useDispatch } from '../utils/redux-utils.js'; -function useDispatchWithMessageID(): ( +function useDispatchWithMessageData(): ( action: SuperAction, - messageID: MessageID, + messageData: MessageData, ) => mixed { const dispatch = useDispatch(); return React.useCallback( - (action: SuperAction, messageID: MessageID) => - dispatch({ ...action, messageID }), + (action: SuperAction, messageData: MessageData) => + dispatch({ ...action, messageData }), [dispatch], ); } -export { useDispatchWithMessageID }; +export { useDispatchWithMessageData }; diff --git a/lib/reducers/db-ops-reducer.js b/lib/reducers/db-ops-reducer.js --- a/lib/reducers/db-ops-reducer.js +++ b/lib/reducers/db-ops-reducer.js @@ -1,7 +1,7 @@ // @flow import { opsProcessingFinishedActionType } from '../actions/db-ops-actions.js'; -import type { MessageID, DBOpsStore } from '../types/db-ops-types.js'; +import type { MessageData, DBOpsStore } from '../types/db-ops-types.js'; import type { BaseAction } from '../types/redux-types.js'; import type { StoreOperations } from '../types/store-ops-types.js'; import { values } from '../utils/objects.js'; @@ -20,23 +20,23 @@ function queueDBOps( store: DBOpsStore, - messageID: ?MessageID, + messageData: ?MessageData, ops: StoreOperations, ): DBOpsStore { const areNewOpsPresent = values(ops).some(opsArray => opsArray.length > 0); let newEntry = null; - if (messageID && areNewOpsPresent) { + if (messageData && areNewOpsPresent) { newEntry = { - messageID, + messageData, ops, }; } else if (areNewOpsPresent) { newEntry = { ops, }; - } else if (messageID) { + } else if (messageData) { newEntry = { - messageID, + messageData, }; } diff --git a/lib/reducers/db-ops-reducer.test.js b/lib/reducers/db-ops-reducer.test.js --- a/lib/reducers/db-ops-reducer.test.js +++ b/lib/reducers/db-ops-reducer.test.js @@ -21,9 +21,9 @@ describe('DB ops reducer', () => { const store: DBOpsStore = { queuedOps: [ - { ops: emptyOps, messageID: '5' }, + { ops: emptyOps, messageData: { messageID: '5', senderDeviceID: '' } }, { ops: emptyOps }, - { ops: null, messageID: '7' }, + { ops: null, messageData: { messageID: '7', senderDeviceID: '' } }, ], }; @@ -32,6 +32,6 @@ type: opsProcessingFinishedActionType, }); expect(newState.queuedOps.length).toEqual(2); - expect(newState.queuedOps[1].messageID).toEqual('7'); + expect(newState.queuedOps[1].messageData?.messageID).toEqual('7'); }); }); diff --git a/lib/types/db-ops-types.js b/lib/types/db-ops-types.js --- a/lib/types/db-ops-types.js +++ b/lib/types/db-ops-types.js @@ -2,11 +2,14 @@ import type { StoreOperations } from './store-ops-types.js'; -export type MessageID = string; +export type MessageData = { + messageID: string, + senderDeviceID: string, +}; export type DBOpsEntry = | { - +messageID: MessageID, + +messageData: MessageData, +ops?: ?StoreOperations, } | { 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 @@ -25,7 +25,7 @@ UpdateUserAvatarResponse, } from './avatar-types.js'; import type { CommunityStore, AddCommunityPayload } from './community-types.js'; -import type { MessageID, DBOpsStore } from './db-ops-types.js'; +import type { MessageData, DBOpsStore } from './db-ops-types.js'; import type { GetVersionActionPayload, LastCommunicatedPlatformDetails, @@ -206,7 +206,7 @@ }; export type BaseAction = $ReadOnly<{ - +messageID?: MessageID, + +messageData?: MessageData, ... | { +type: '@@redux/INIT', @@ -1406,7 +1406,7 @@ +loadingInfo?: LoadingInfo, +error?: boolean, +dispatchSource?: DispatchSource, - +messageID?: MessageID, + +messageData?: MessageData, }; type ThunkedAction = (dispatch: Dispatch) => void; export type PromisedAction = (dispatch: Dispatch) => Promise; diff --git a/lib/types/request-types.js b/lib/types/request-types.js --- a/lib/types/request-types.js +++ b/lib/types/request-types.js @@ -6,7 +6,7 @@ import { type ActivityUpdate } from './activity-types.js'; import type { SignedIdentityKeysBlob } from './crypto-types.js'; import { signedIdentityKeysBlobValidator } from './crypto-types.js'; -import type { MessageID } from './db-ops-types.js'; +import type { MessageData } from './db-ops-types.js'; import type { Platform, PlatformDetails } from './device-types.js'; import { type RawEntryInfo, @@ -268,7 +268,7 @@ +keyserverID: string, }; export type ProcessServerRequestAction = { - +messageID?: MessageID, + +messageData?: MessageData, +type: 'PROCESS_SERVER_REQUESTS', +payload: ProcessServerRequestsPayload, }; diff --git a/native/redux/action-types.js b/native/redux/action-types.js --- a/native/redux/action-types.js +++ b/native/redux/action-types.js @@ -3,7 +3,7 @@ import type { Orientations } from 'react-native-orientation-locker'; import { saveMessagesActionType } from 'lib/actions/message-actions.js'; -import type { MessageID } from 'lib/types/db-ops-types'; +import type { MessageData } from 'lib/types/db-ops-types'; import type { BaseAction } from 'lib/types/redux-types.js'; import type { DimensionsInfo } from './dimensions-updater.react.js'; @@ -27,7 +27,7 @@ export type Action = $ReadOnly< | BaseAction | { - +messageID?: MessageID, + +messageData?: MessageData, ... | { +type: 'SET_REDUX_STATE', 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 @@ -333,7 +333,7 @@ }; state = { ...state, - dbOpsStore: queueDBOps(state.dbOpsStore, action.messageID, ops), + dbOpsStore: queueDBOps(state.dbOpsStore, action.messageData, ops), }; return state; 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 @@ -37,7 +37,7 @@ import type { AlertStore } from 'lib/types/alert-types.js'; import type { AuxUserStore } from 'lib/types/aux-user-types.js'; import type { CommunityStore } from 'lib/types/community-types.js'; -import type { MessageID, DBOpsStore } from 'lib/types/db-ops-types.js'; +import type { MessageData, DBOpsStore } from 'lib/types/db-ops-types.js'; import type { DraftStore } from 'lib/types/draft-types.js'; import type { EnabledApps } from 'lib/types/enabled-apps.js'; import type { EntryStore } from 'lib/types/entry-types.js'; @@ -133,7 +133,7 @@ export type Action = $ReadOnly< | BaseAction | { - +messageID?: MessageID, + +messageData?: MessageData, ... | { +type: 'UPDATE_NAV_INFO', +payload: Partial } | { @@ -549,7 +549,11 @@ return { ...state, - dbOpsStore: queueDBOps(state.dbOpsStore, action.messageID, storeOperations), + dbOpsStore: queueDBOps( + state.dbOpsStore, + action.messageData, + storeOperations, + ), }; }