Page MenuHomePhabricator

D13217.diff
No OneTemporary

D13217.diff

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

Mime Type
text/plain
Expires
Fri, Nov 8, 5:43 PM (21 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2444815
Default Alt Text
D13217.diff (3 KB)

Event Timeline