Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3383916
D8617.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D8617.diff
View Options
diff --git a/lib/ops/message-store-ops.js b/lib/ops/message-store-ops.js
new file mode 100644
--- /dev/null
+++ b/lib/ops/message-store-ops.js
@@ -0,0 +1,78 @@
+// @flow
+
+import type {
+ ClientDBMessageInfo,
+ ClientDBThreadMessageInfo,
+ MessageStoreThreads,
+ RawMessageInfo,
+} from '../types/message-types.js';
+
+// MessageStore messages ops
+export type RemoveMessageOperation = {
+ +type: 'remove',
+ +payload: { +ids: $ReadOnlyArray<string> },
+};
+
+export type RemoveMessagesForThreadsOperation = {
+ +type: 'remove_messages_for_threads',
+ +payload: { +threadIDs: $ReadOnlyArray<string> },
+};
+
+export type ReplaceMessageOperation = {
+ +type: 'replace',
+ +payload: { +id: string, +messageInfo: RawMessageInfo },
+};
+
+export type RekeyMessageOperation = {
+ +type: 'rekey',
+ +payload: { +from: string, +to: string },
+};
+
+export type RemoveAllMessagesOperation = {
+ +type: 'remove_all',
+};
+
+// MessageStore threads ops
+export type ReplaceMessageStoreThreadsOperation = {
+ +type: 'replace_threads',
+ +payload: { +threads: MessageStoreThreads },
+};
+
+export type RemoveMessageStoreThreadsOperation = {
+ +type: 'remove_threads',
+ +payload: { +ids: $ReadOnlyArray<string> },
+};
+
+export type RemoveMessageStoreAllThreadsOperation = {
+ +type: 'remove_all_threads',
+};
+
+export type ClientDBReplaceMessageOperation = {
+ +type: 'replace',
+ +payload: ClientDBMessageInfo,
+};
+
+export type ClientDBReplaceThreadsOperation = {
+ +type: 'replace_threads',
+ +payload: { +threads: $ReadOnlyArray<ClientDBThreadMessageInfo> },
+};
+
+export type MessageStoreOperation =
+ | RemoveMessageOperation
+ | ReplaceMessageOperation
+ | RekeyMessageOperation
+ | RemoveMessagesForThreadsOperation
+ | RemoveAllMessagesOperation
+ | ReplaceMessageStoreThreadsOperation
+ | RemoveMessageStoreThreadsOperation
+ | RemoveMessageStoreAllThreadsOperation;
+
+export type ClientDBMessageStoreOperation =
+ | RemoveMessageOperation
+ | ClientDBReplaceMessageOperation
+ | RekeyMessageOperation
+ | RemoveMessagesForThreadsOperation
+ | RemoveAllMessagesOperation
+ | ClientDBReplaceThreadsOperation
+ | RemoveMessageStoreThreadsOperation
+ | RemoveMessageStoreAllThreadsOperation;
diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js
--- a/lib/reducers/message-reducer.js
+++ b/lib/reducers/message-reducer.js
@@ -53,6 +53,10 @@
logInActionTypes,
registerActionTypes,
} from '../actions/user-actions.js';
+import type {
+ MessageStoreOperation,
+ ReplaceMessageOperation,
+} from '../ops/message-store-ops.js';
import { pendingToRealizedThreadIDsSelector } from '../selectors/thread-selectors.js';
import {
messageID,
@@ -74,8 +78,6 @@
type RawMessageInfo,
type LocalMessageInfo,
type MessageStore,
- type ReplaceMessageOperation,
- type MessageStoreOperation,
type MessageTruncationStatus,
type MessageTruncationStatuses,
messageTruncationStatus,
diff --git a/lib/types/message-types.js b/lib/types/message-types.js
--- a/lib/types/message-types.js
+++ b/lib/types/message-types.js
@@ -2,14 +2,14 @@
import invariant from 'invariant';
import t, {
- type TUnion,
type TDict,
type TEnums,
type TInterface,
+ type TUnion,
} from 'tcomb';
import { type ClientDBMediaInfo } from './media-types.js';
-import { messageTypes, type MessageType } from './message-types-enum.js';
+import { type MessageType, messageTypes } from './message-types-enum.js';
import {
type AddMembersMessageData,
type AddMembersMessageInfo,
@@ -65,10 +65,10 @@
rawEditEntryMessageInfoValidator,
} from './messages/edit-entry.js';
import {
- type RawEditMessageInfo,
- rawEditMessageInfoValidator,
type EditMessageData,
type EditMessageInfo,
+ type RawEditMessageInfo,
+ rawEditMessageInfoValidator,
} from './messages/edit.js';
import {
type ImagesMessageData,
@@ -96,9 +96,9 @@
rawMediaMessageInfoValidator,
} from './messages/media.js';
import {
- type ReactionMessageData,
type RawReactionMessageInfo,
rawReactionMessageInfoValidator,
+ type ReactionMessageData,
type ReactionMessageInfo,
} from './messages/reaction.js';
import {
@@ -120,10 +120,10 @@
type TextMessageInfo,
} from './messages/text.js';
import {
- type TogglePinMessageData,
- type TogglePinMessageInfo,
type RawTogglePinMessageInfo,
rawTogglePinMessageInfoValidator,
+ type TogglePinMessageData,
+ type TogglePinMessageInfo,
} from './messages/toggle-pin.js';
import {
type RawUnsupportedMessageInfo,
@@ -139,7 +139,7 @@
import { type RelativeUserInfo, type UserInfos } from './user-types.js';
import type { CallServerEndpointResultInfoInterface } from '../utils/call-server-endpoint.js';
import { values } from '../utils/objects.js';
-import { tNumber, tShape, tID } from '../utils/validation-utils.js';
+import { tID, tNumber, tShape } from '../utils/validation-utils.js';
const composableMessageTypes = new Set([
messageTypes.TEXT,
@@ -431,46 +431,6 @@
currentAsOf: t.Number,
});
-// MessageStore messages ops
-export type RemoveMessageOperation = {
- +type: 'remove',
- +payload: { +ids: $ReadOnlyArray<string> },
-};
-
-export type RemoveMessagesForThreadsOperation = {
- +type: 'remove_messages_for_threads',
- +payload: { +threadIDs: $ReadOnlyArray<string> },
-};
-
-export type ReplaceMessageOperation = {
- +type: 'replace',
- +payload: { +id: string, +messageInfo: RawMessageInfo },
-};
-
-export type RekeyMessageOperation = {
- +type: 'rekey',
- +payload: { +from: string, +to: string },
-};
-
-export type RemoveAllMessagesOperation = {
- +type: 'remove_all',
-};
-
-// MessageStore threads ops
-export type ReplaceMessageStoreThreadsOperation = {
- +type: 'replace_threads',
- +payload: { +threads: MessageStoreThreads },
-};
-
-export type RemoveMessageStoreThreadsOperation = {
- +type: 'remove_threads',
- +payload: { +ids: $ReadOnlyArray<string> },
-};
-
-export type RemoveMessageStoreAllThreadsOperation = {
- +type: 'remove_all_threads',
-};
-
// We were initially using `number`s` for `thread`, `type`, `future_type`, etc.
// However, we ended up changing `thread` to `string` to account for thread IDs
// including information about the keyserver (eg 'GENESIS|123') in the future.
@@ -493,11 +453,6 @@
+media_infos: ?$ReadOnlyArray<ClientDBMediaInfo>,
};
-export type ClientDBReplaceMessageOperation = {
- +type: 'replace',
- +payload: ClientDBMessageInfo,
-};
-
export type ClientDBThreadMessageInfo = {
+id: string,
+start_reached: string,
@@ -505,31 +460,6 @@
+last_pruned: string,
};
-export type ClientDBReplaceThreadsOperation = {
- +type: 'replace_threads',
- +payload: { +threads: $ReadOnlyArray<ClientDBThreadMessageInfo> },
-};
-
-export type MessageStoreOperation =
- | RemoveMessageOperation
- | ReplaceMessageOperation
- | RekeyMessageOperation
- | RemoveMessagesForThreadsOperation
- | RemoveAllMessagesOperation
- | ReplaceMessageStoreThreadsOperation
- | RemoveMessageStoreThreadsOperation
- | RemoveMessageStoreAllThreadsOperation;
-
-export type ClientDBMessageStoreOperation =
- | RemoveMessageOperation
- | ClientDBReplaceMessageOperation
- | RekeyMessageOperation
- | RemoveMessagesForThreadsOperation
- | RemoveAllMessagesOperation
- | ClientDBReplaceThreadsOperation
- | RemoveMessageStoreThreadsOperation
- | RemoveMessageStoreAllThreadsOperation;
-
export const messageTruncationStatus = Object.freeze({
// EXHAUSTIVE means we've reached the start of the thread. Either the result
// set includes the very first message for that thread, or there is nothing
diff --git a/lib/types/store-ops-types.js b/lib/types/store-ops-types.js
--- a/lib/types/store-ops-types.js
+++ b/lib/types/store-ops-types.js
@@ -7,11 +7,13 @@
} from './draft-types.js';
import type {
ClientDBMessageInfo,
- ClientDBMessageStoreOperation,
- MessageStoreOperation,
ClientDBThreadMessageInfo,
} from './message-types.js';
import type { ClientDBThreadInfo } from './thread-types.js';
+import type {
+ ClientDBMessageStoreOperation,
+ MessageStoreOperation,
+} from '../ops/message-store-ops.js';
import type {
ReportStoreOperation,
ClientDBReport,
diff --git a/lib/utils/message-ops-utils.js b/lib/utils/message-ops-utils.js
--- a/lib/utils/message-ops-utils.js
+++ b/lib/utils/message-ops-utils.js
@@ -7,6 +7,10 @@
encryptedMediaBlobURI,
encryptedVideoThumbnailBlobURI,
} from '../media/media-utils.js';
+import type {
+ ClientDBMessageStoreOperation,
+ MessageStoreOperation,
+} from '../ops/message-store-ops.js';
import { messageID } from '../shared/message-utils.js';
import { messageSpecs } from '../shared/messages/message-specs.js';
import type {
@@ -23,8 +27,6 @@
import {
type ClientDBMessageInfo,
type RawMessageInfo,
- type MessageStoreOperation,
- type ClientDBMessageStoreOperation,
type ClientDBThreadMessageInfo,
type ThreadMessageInfo,
type MessageStoreThreads,
diff --git a/native/redux/client-db-utils.js b/native/redux/client-db-utils.js
--- a/native/redux/client-db-utils.js
+++ b/native/redux/client-db-utils.js
@@ -1,8 +1,8 @@
// @flow
+import type { ClientDBMessageStoreOperation } from 'lib/ops/message-store-ops.js';
import type { ClientDBThreadStoreOperation } from 'lib/ops/thread-store-ops.js';
import type {
- ClientDBMessageStoreOperation,
RawMessageInfo,
ClientDBMessageInfo,
ClientDBThreadMessageInfo,
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -15,6 +15,7 @@
convertCalendarFilterToNewIDSchema,
convertConnectionInfoToNewIDSchema,
} from 'lib/_generated/migration-utils.js';
+import type { ClientDBMessageStoreOperation } from 'lib/ops/message-store-ops.js';
import {
type ReportStoreOperation,
type ClientDBReportStoreOperation,
@@ -39,7 +40,6 @@
import {
type LocalMessageInfo,
type MessageStore,
- type ClientDBMessageStoreOperation,
} from 'lib/types/message-types.js';
import type {
ReportStore,
diff --git a/native/redux/unshim-utils.js b/native/redux/unshim-utils.js
--- a/native/redux/unshim-utils.js
+++ b/native/redux/unshim-utils.js
@@ -1,11 +1,9 @@
// @flow
+import type { ClientDBMessageStoreOperation } from 'lib/ops/message-store-ops.js';
import { unshimFunc } from 'lib/shared/unshim-utils.js';
import { type MessageType } from 'lib/types/message-types-enum.js';
-import type {
- ClientDBMessageStoreOperation,
- ClientDBMessageInfo,
-} from 'lib/types/message-types.js';
+import type { ClientDBMessageInfo } from 'lib/types/message-types.js';
import {
translateClientDBMessageInfoToRawMessageInfo,
translateRawMessageInfoToClientDBMessageInfo,
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -5,14 +5,12 @@
import { TurboModuleRegistry } from 'react-native';
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport.js';
+import type { ClientDBMessageStoreOperation } from 'lib/ops/message-store-ops.js';
import type { ClientDBReportStoreOperation } from 'lib/ops/report-store-ops.js';
import type { ClientDBThreadStoreOperation } from 'lib/ops/thread-store-ops.js';
import type { OLMOneTimeKeys } from 'lib/types/crypto-types';
import type { ClientDBDraftStoreOperation } from 'lib/types/draft-types.js';
-import type {
- ClientDBMessageInfo,
- ClientDBMessageStoreOperation,
-} from 'lib/types/message-types.js';
+import type { ClientDBMessageInfo } from 'lib/types/message-types.js';
import type { ClientDBStore } from 'lib/types/store-ops-types';
import type { ClientDBThreadInfo } from 'lib/types/thread-types.js';
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 29, 6:16 PM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2597762
Default Alt Text
D8617.diff (11 KB)
Attached To
Mode
D8617: [lib] extract MessageStore ops types to a separate file
Attached
Detach File
Event Timeline
Log In to Comment