Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3299831
D13400.id44358.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D13400.id44358.diff
View Options
diff --git a/lib/shared/dm-ops/dm-ops-queue-handler.react.js b/lib/shared/dm-ops/dm-ops-queue-handler.react.js
--- a/lib/shared/dm-ops/dm-ops-queue-handler.react.js
+++ b/lib/shared/dm-ops/dm-ops-queue-handler.react.js
@@ -17,7 +17,6 @@
pruneDMOpsQueueActionType,
} from '../../types/dm-ops.js';
import type { OperationsQueue } from '../../types/dm-ops.js';
-import { threadTypeIsThick } from '../../types/thread-types-enum.js';
import { useDispatch, useSelector } from '../../utils/redux-utils.js';
const PRUNING_FREQUENCY = 60 * 60 * 1000;
@@ -48,16 +47,7 @@
}, [prune]);
const threadInfos = useSelector(threadInfoSelector);
- const threadIDs = React.useMemo(
- () =>
- new Set(
- Object.entries(threadInfos)
- .filter(([, threadInfo]) => threadTypeIsThick(threadInfo.type))
- .map(([id]) => id),
- ),
- [threadInfos],
- );
- const prevThreadIDsRef = React.useRef<$ReadOnlySet<string>>(new Set());
+ const prevThreadInfosRef = React.useRef({});
const queuedThreadOperations = useSelector(
state => state.queuedDMOperations.threadQueue,
@@ -83,11 +73,11 @@
);
React.useEffect(() => {
- const prevThreadIDs = prevThreadIDsRef.current;
- prevThreadIDsRef.current = threadIDs;
+ const prevThreadInfos = prevThreadInfosRef.current;
+ prevThreadInfosRef.current = threadInfos;
for (const threadID in queuedThreadOperations) {
- if (!threadIDs.has(threadID) || prevThreadIDs.has(threadID)) {
+ if (!threadInfos[threadID] || prevThreadInfos[threadID]) {
continue;
}
processOperationsQueue(queuedThreadOperations[threadID]);
@@ -98,34 +88,21 @@
},
});
}
- }, [dispatch, processOperationsQueue, queuedThreadOperations, threadIDs]);
+ }, [dispatch, processOperationsQueue, queuedThreadOperations, threadInfos]);
const messageInfos = useSelector(messageInfoSelector);
- const messageIDs = React.useMemo(
- () =>
- new Set(
- Object.entries(messageInfos)
- .filter(
- ([, messageInfo]) =>
- messageInfo &&
- threadTypeIsThick(threadInfos[messageInfo.threadID]?.type),
- )
- .map(([id]) => id),
- ),
- [messageInfos, threadInfos],
- );
- const prevMessageIDsRef = React.useRef<$ReadOnlySet<string>>(new Set());
+ const prevMessageInfosRef = React.useRef({});
const queuedMessageOperations = useSelector(
state => state.queuedDMOperations.messageQueue,
);
React.useEffect(() => {
- const prevMessageIDs = prevMessageIDsRef.current;
- prevMessageIDsRef.current = messageIDs;
+ const prevMessageInfos = prevMessageInfosRef.current;
+ prevMessageInfosRef.current = messageInfos;
for (const messageID in queuedMessageOperations) {
- if (!messageIDs.has(messageID) || prevMessageIDs.has(messageID)) {
+ if (!messageInfos[messageID] || prevMessageInfos[messageID]) {
continue;
}
processOperationsQueue(queuedMessageOperations[messageID]);
@@ -136,32 +113,21 @@
},
});
}
- }, [dispatch, messageIDs, processOperationsQueue, queuedMessageOperations]);
+ }, [dispatch, messageInfos, processOperationsQueue, queuedMessageOperations]);
const entryInfos = useSelector(entryInfoSelector);
- const entryIDs = React.useMemo(
- () =>
- new Set(
- Object.entries(entryInfos)
- .filter(([, entryInfo]) =>
- threadTypeIsThick(threadInfos[entryInfo.threadID]?.type),
- )
- .map(([id]) => id),
- ),
- [entryInfos, threadInfos],
- );
- const prevEntryIDsRef = React.useRef<$ReadOnlySet<string>>(new Set());
+ const prevEntryInfosRef = React.useRef({});
const queuedEntryOperations = useSelector(
state => state.queuedDMOperations.entryQueue,
);
React.useEffect(() => {
- const prevEntryIDs = prevEntryIDsRef.current;
- prevEntryIDsRef.current = entryIDs;
+ const prevEntryInfos = prevEntryInfosRef.current;
+ prevEntryInfosRef.current = entryInfos;
for (const entryID in queuedEntryOperations) {
- if (!entryIDs.has(entryID) || prevEntryIDs.has(entryID)) {
+ if (!entryInfos[entryID] || prevEntryInfos[entryID]) {
continue;
}
processOperationsQueue(queuedEntryOperations[entryID]);
@@ -172,7 +138,7 @@
},
});
}
- }, [dispatch, entryIDs, processOperationsQueue, queuedEntryOperations]);
+ }, [dispatch, entryInfos, processOperationsQueue, queuedEntryOperations]);
const queuedMembershipOperations = useSelector(
state => state.queuedDMOperations.membershipQueue,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 3:49 PM (21 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2535197
Default Alt Text
D13400.id44358.diff (4 KB)
Attached To
Mode
D13400: [lib] Avoid unnecessary sets creation
Attached
Detach File
Event Timeline
Log In to Comment