Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33084049
D15152.1768455811.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D15152.1768455811.diff
View Options
diff --git a/lib/reducers/dm-operations-queue-reducer.js b/lib/reducers/dm-operations-queue-reducer.js
--- a/lib/reducers/dm-operations-queue-reducer.js
+++ b/lib/reducers/dm-operations-queue-reducer.js
@@ -10,6 +10,7 @@
clearQueuedThreadDMOpsActionType,
type OperationsQueue,
pruneDMOpsQueueActionType,
+ queuedDMOperationConditionType,
type QueuedDMOperations,
queueDMOpsActionType,
reportUnshimmingOperationCompletedActionType,
@@ -27,7 +28,7 @@
if (action.type === queueDMOpsActionType) {
const { condition, operation, timestamp } = action.payload;
- if (condition.type === 'thread') {
+ if (condition.type === queuedDMOperationConditionType.THREAD) {
return {
store: {
...store,
@@ -43,7 +44,7 @@
};
}
- if (condition.type === 'entry') {
+ if (condition.type === queuedDMOperationConditionType.ENTRY) {
return {
store: {
...store,
@@ -59,7 +60,7 @@
};
}
- if (condition.type === 'message') {
+ if (condition.type === queuedDMOperationConditionType.MESSAGE) {
return {
store: {
...store,
diff --git a/lib/shared/dm-ops/process-dm-ops.js b/lib/shared/dm-ops/process-dm-ops.js
--- a/lib/shared/dm-ops/process-dm-ops.js
+++ b/lib/shared/dm-ops/process-dm-ops.js
@@ -33,6 +33,7 @@
dmOperationValidator,
type ProcessDMOpsPayload,
saveUnsupportedOperationActionType,
+ queuedDMOperationConditionType,
} from '../../types/dm-ops.js';
import type { RawMessageInfo } from '../../types/message-types.js';
import type { DispatchMetadata } from '../../types/redux-types.js';
@@ -188,22 +189,22 @@
let condition;
if (processingCheckResult.reason.type === 'missing_thread') {
condition = {
- type: 'thread',
+ type: queuedDMOperationConditionType.THREAD,
threadID: processingCheckResult.reason.threadID,
};
} else if (processingCheckResult.reason.type === 'missing_entry') {
condition = {
- type: 'entry',
+ type: queuedDMOperationConditionType.ENTRY,
entryID: processingCheckResult.reason.entryID,
};
} else if (processingCheckResult.reason.type === 'missing_message') {
condition = {
- type: 'message',
+ type: queuedDMOperationConditionType.MESSAGE,
messageID: processingCheckResult.reason.messageID,
};
} else if (processingCheckResult.reason.type === 'missing_membership') {
condition = {
- type: 'membership',
+ type: queuedDMOperationConditionType.MEMBERSHIP,
threadID: processingCheckResult.reason.threadID,
userID: processingCheckResult.reason.userID,
};
diff --git a/lib/types/dm-ops.js b/lib/types/dm-ops.js
--- a/lib/types/dm-ops.js
+++ b/lib/types/dm-ops.js
@@ -1,5 +1,6 @@
// @flow
+import invariant from 'invariant';
import t, { type TInterface, type TUnion } from 'tcomb';
import { clientAvatarValidator, type ClientAvatar } from './avatar-types.js';
@@ -555,28 +556,53 @@
+messagesNotifyTypes: { +[messageID: string]: MessageNotifyType },
};
+export const queuedDMOperationConditionType = Object.freeze({
+ THREAD: 'thread',
+ ENTRY: 'entry',
+ MESSAGE: 'message',
+ MEMBERSHIP: 'membership',
+});
+export type QueuedDMOperationCondition = $Values<
+ typeof queuedDMOperationConditionType,
+>;
+
+export function assertQueuedDMOperationCondition(
+ queuedDMOperationCondition: string,
+): QueuedDMOperationCondition {
+ invariant(
+ queuedDMOperationCondition === 'thread' ||
+ queuedDMOperationCondition === 'entry' ||
+ queuedDMOperationCondition === 'message' ||
+ queuedDMOperationCondition === 'membership',
+ 'string is not QueuedDMOperationCondition enum',
+ );
+ return queuedDMOperationCondition;
+}
+
+export type QueueDMOpsCondition =
+ | {
+ +type: 'thread',
+ +threadID: string,
+ }
+ | {
+ +type: 'entry',
+ +entryID: string,
+ }
+ | {
+ +type: 'message',
+ +messageID: string,
+ }
+ | {
+ +type: 'membership',
+ +threadID: string,
+ +userID: string,
+ };
+
export const queueDMOpsActionType = 'QUEUE_DM_OPS';
export type QueueDMOpsPayload = {
+operation: DMOperation,
+timestamp: number,
- +condition:
- | {
- +type: 'thread',
- +threadID: string,
- }
- | {
- +type: 'entry',
- +entryID: string,
- }
- | {
- +type: 'message',
- +messageID: string,
- }
- | {
- +type: 'membership',
- +threadID: string,
- +userID: string,
- },
+ +condition: QueueDMOpsCondition,
};
export const pruneDMOpsQueueActionType = 'PRUNE_DM_OPS_QUEUE';
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 15, 5:43 AM (6 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5936306
Default Alt Text
D15152.1768455811.diff (4 KB)
Attached To
Mode
D15152: [lib] extract `QueueDMOpsPayload` condition type
Attached
Detach File
Event Timeline
Log In to Comment