Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3364935
D13217.id43933.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13217.id43933.diff
View Options
diff --git a/lib/shared/dm-ops/join-thread-spec.js b/lib/shared/dm-ops/join-thread-spec.js
--- a/lib/shared/dm-ops/join-thread-spec.js
+++ b/lib/shared/dm-ops/join-thread-spec.js
@@ -50,22 +50,56 @@
const currentThreadInfo =
utilities.threadInfos[existingThreadDetails.threadID];
+ if (currentThreadInfo && !currentThreadInfo.thick) {
+ return {
+ rawMessageInfos: [],
+ updateInfos: [],
+ };
+ }
const messageData = createMessageDataFromDMOperation(dmOperation);
const joinThreadMessageInfos = [
rawMessageInfoFromMessageData(messageData, messageID),
];
- if (userIsMember(currentThreadInfo, joinerID)) {
+ const memberTimestamps = { ...currentThreadInfo?.timestamps?.members };
+ if (!memberTimestamps[joinerID]) {
+ memberTimestamps[joinerID] = {
+ isMember: time,
+ subscription: existingThreadDetails.creationTime,
+ };
+ }
+
+ if (memberTimestamps[joinerID].isMember > time) {
return {
rawMessageInfos: joinThreadMessageInfos,
updateInfos: [],
};
}
+ memberTimestamps[joinerID] = {
+ ...memberTimestamps[joinerID],
+ isMember: time,
+ };
+
const updateInfos: Array<ClientUpdateInfo> = [];
const rawMessageInfos: Array<RawMessageInfo> = [];
- if (viewerID === joinerID) {
+
+ if (userIsMember(currentThreadInfo, joinerID)) {
+ rawMessageInfos.push(...joinThreadMessageInfos);
+ updateInfos.push({
+ type: updateTypes.UPDATE_THREAD,
+ id: uuid.v4(),
+ time,
+ threadInfo: {
+ ...currentThreadInfo,
+ timestamps: {
+ ...currentThreadInfo.timestamps,
+ members: memberTimestamps,
+ },
+ },
+ });
+ } else if (viewerID === joinerID) {
const newThreadInfo = createThickRawThreadInfo(
{
...existingThreadDetails,
@@ -80,14 +114,18 @@
type: updateTypes.JOIN_THREAD,
id: uuid.v4(),
time,
- threadInfo: newThreadInfo,
+ threadInfo: {
+ ...newThreadInfo,
+ timestamps: {
+ ...newThreadInfo.timestamps,
+ members: memberTimestamps,
+ },
+ },
rawMessageInfos: joinThreadMessageInfos,
truncationStatus: messageTruncationStatus.EXHAUSTIVE,
rawEntryInfos: [],
});
} else {
- invariant(currentThreadInfo.thick, 'Thread should be thick');
-
rawMessageInfos.push(...joinThreadMessageInfos);
const defaultRoleID = values(currentThreadInfo.roles).find(role =>
roleIsDefaultRole(role),
@@ -109,6 +147,10 @@
const updatedThreadInfo = {
...currentThreadInfo,
members: [...currentThreadInfo.members, member],
+ timestamps: {
+ ...currentThreadInfo.timestamps,
+ members: memberTimestamps,
+ },
};
updateInfos.push({
type: updateTypes.UPDATE_THREAD,
@@ -127,7 +169,10 @@
viewerID: string,
utilities: ProcessDMOperationUtilities,
) {
- if (utilities.threadInfos[dmOperation.existingThreadDetails.threadID]) {
+ if (
+ utilities.threadInfos[dmOperation.existingThreadDetails.threadID] ||
+ dmOperation.joinerID === viewerID
+ ) {
return { isProcessingPossible: true };
}
return {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 5:52 AM (21 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2583166
Default Alt Text
D13217.id43933.diff (3 KB)
Attached To
Mode
D13217: [lib] Check the timestamps when joining threads
Attached
Detach File
Event Timeline
Log In to Comment