Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3337054
D11730.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D11730.diff
View Options
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 { MessageSourceMetadata } from '../types/db-ops-types.js';
import type { SuperAction } from '../types/redux-types.js';
import { useDispatch } from '../utils/redux-utils.js';
-function useDispatchWithMessageID(): (
+function useDispatchWithMessageSource(): (
action: SuperAction,
- messageID: MessageID,
+ messageSourceMetadata: MessageSourceMetadata,
) => mixed {
const dispatch = useDispatch();
return React.useCallback(
- (action: SuperAction, messageID: MessageID) =>
- dispatch({ ...action, messageID }),
+ (action: SuperAction, messageSourceMetadata: MessageSourceMetadata) =>
+ dispatch({ ...action, messageSourceMetadata }),
[dispatch],
);
}
-export { useDispatchWithMessageID };
+export { useDispatchWithMessageSource };
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,10 @@
// @flow
import { opsProcessingFinishedActionType } from '../actions/db-ops-actions.js';
-import type { MessageID, DBOpsStore } from '../types/db-ops-types.js';
+import type {
+ MessageSourceMetadata,
+ 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 +23,23 @@
function queueDBOps(
store: DBOpsStore,
- messageID: ?MessageID,
+ messageSourceMetadata: ?MessageSourceMetadata,
ops: StoreOperations,
): DBOpsStore {
const areNewOpsPresent = values(ops).some(opsArray => opsArray.length > 0);
let newEntry = null;
- if (messageID && areNewOpsPresent) {
+ if (messageSourceMetadata && areNewOpsPresent) {
newEntry = {
- messageID,
+ messageSourceMetadata,
ops,
};
} else if (areNewOpsPresent) {
newEntry = {
ops,
};
- } else if (messageID) {
+ } else if (messageSourceMetadata) {
newEntry = {
- messageID,
+ messageSourceMetadata,
};
}
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,15 @@
describe('DB ops reducer', () => {
const store: DBOpsStore = {
queuedOps: [
- { ops: emptyOps, messageID: '5' },
+ {
+ ops: emptyOps,
+ messageSourceMetadata: { messageID: '5', senderDeviceID: '' },
+ },
{ ops: emptyOps },
- { ops: null, messageID: '7' },
+ {
+ ops: null,
+ messageSourceMetadata: { messageID: '7', senderDeviceID: '' },
+ },
],
};
@@ -32,6 +38,6 @@
type: opsProcessingFinishedActionType,
});
expect(newState.queuedOps.length).toEqual(2);
- expect(newState.queuedOps[1].messageID).toEqual('7');
+ expect(newState.queuedOps[1].messageSourceMetadata?.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 MessageSourceMetadata = {
+ +messageID: string,
+ +senderDeviceID: string,
+};
export type DBOpsEntry =
| {
- +messageID: MessageID,
+ +messageSourceMetadata: MessageSourceMetadata,
+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 { MessageSourceMetadata, DBOpsStore } from './db-ops-types.js';
import type {
GetVersionActionPayload,
LastCommunicatedPlatformDetails,
@@ -206,7 +206,7 @@
};
export type BaseAction = $ReadOnly<{
- +messageID?: MessageID,
+ +messageSourceMetadata?: MessageSourceMetadata,
...
| {
+type: '@@redux/INIT',
@@ -1402,7 +1402,7 @@
+loadingInfo?: LoadingInfo,
+error?: boolean,
+dispatchSource?: DispatchSource,
- +messageID?: MessageID,
+ +messageSourceMetadata?: MessageSourceMetadata,
};
type ThunkedAction = (dispatch: Dispatch) => void;
export type PromisedAction = (dispatch: Dispatch) => Promise<void>;
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 { MessageSourceMetadata } 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,
+ +messageSourceMetadata?: MessageSourceMetadata,
+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 { MessageSourceMetadata } from 'lib/types/db-ops-types.js';
import type { BaseAction } from 'lib/types/redux-types.js';
import type { DimensionsInfo } from './dimensions-updater.react.js';
@@ -28,7 +28,7 @@
export type Action = $ReadOnly<
| BaseAction
| {
- +messageID?: MessageID,
+ +messageSourceMetadata?: MessageSourceMetadata,
...
| {
+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
@@ -336,7 +336,7 @@
};
state = {
...state,
- dbOpsStore: queueDBOps(state.dbOpsStore, action.messageID, ops),
+ dbOpsStore: queueDBOps(state.dbOpsStore, action.messageSourceMetadata, 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,10 @@
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 {
+ MessageSourceMetadata,
+ 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 +136,7 @@
export type Action = $ReadOnly<
| BaseAction
| {
- +messageID?: MessageID,
+ +messageSourceMetadata?: MessageSourceMetadata,
...
| { +type: 'UPDATE_NAV_INFO', +payload: Partial<WebNavInfo> }
| {
@@ -549,7 +552,11 @@
return {
...state,
- dbOpsStore: queueDBOps(state.dbOpsStore, action.messageID, storeOperations),
+ dbOpsStore: queueDBOps(
+ state.dbOpsStore,
+ action.messageSourceMetadata,
+ storeOperations,
+ ),
};
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 3:32 PM (19 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2562385
Default Alt Text
D11730.diff (7 KB)
Attached To
Mode
D11730: [lib/web/native] update `MessageID` in ops handling
Attached
Detach File
Event Timeline
Log In to Comment