Page MenuHomePhabricator

D13241.diff
No OneTemporary

D13241.diff

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
@@ -1,5 +1,6 @@
// @flow
+import invariant from 'invariant';
import _groupBy from 'lodash/fp/groupBy.js';
import * as React from 'react';
import uuid from 'uuid';
@@ -31,7 +32,6 @@
import type { RawThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js';
import type { DispatchMetadata } from '../../types/redux-types.js';
import type { OutboundP2PMessage } from '../../types/sqlite-types.js';
-import { threadTypes } from '../../types/thread-types-enum.js';
import type { LegacyRawThreadInfo } from '../../types/thread-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
import { extractUserIDsFromPayload } from '../../utils/conversion-utils.js';
@@ -194,10 +194,7 @@
const updatedThreadInfo = updateSpecs[
update.type
].getUpdatedThreadInfo?.(update, updatedThreadInfosByThreadID);
- if (
- updatedThreadInfo &&
- updatedThreadInfo?.type === threadTypes.THICK_SIDEBAR
- ) {
+ if (updatedThreadInfo) {
updatedThreadInfosByThreadID[updatedThreadInfo.id] =
updatedThreadInfo;
}
@@ -207,8 +204,10 @@
const repliesCountIncreasingMessages = messagesByThreadID[
threadID
].filter(message => messageSpecs[message.type].includedInRepliesCount);
+
+ const threadInfo = updatedThreadInfosByThreadID[threadID];
+
if (repliesCountIncreasingMessages.length > 0) {
- const threadInfo = updatedThreadInfosByThreadID[threadID];
const repliesCountIncreaseTime = Math.max(
repliesCountIncreasingMessages.map(message => message.time),
);
@@ -230,17 +229,52 @@
if (messagesFromOtherPeers.length === 0) {
continue;
}
- // We take the most recent timestamp to make sure that updates older
+ // We take the most recent timestamp to make sure that
+ // change_thread_read_status operation older
// than it won't flip the status to read.
const time = Math.max(
messagesFromOtherPeers.map(message => message.time),
);
+ invariant(threadInfo.thick, 'Thread should be thick');
+
+ // We aren't checking if the unread timestamp is lower than the time.
+ // We're doing this because we want to flip the thread to unread after
+ // any new message from a non-viewer.
+ const updatedThreadInfo = threadInfo.minimallyEncoded
+ ? {
+ ...threadInfo,
+ currentUser: {
+ ...threadInfo.currentUser,
+ unread: true,
+ },
+ timestamps: {
+ ...threadInfo.timestamps,
+ currentUser: {
+ ...threadInfo.timestamps.currentUser,
+ unread: time,
+ },
+ },
+ }
+ : {
+ ...threadInfo,
+ currentUser: {
+ ...threadInfo.currentUser,
+ unread: true,
+ },
+ timestamps: {
+ ...threadInfo.timestamps,
+ currentUser: {
+ ...threadInfo.timestamps.currentUser,
+ unread: time,
+ },
+ },
+ };
+
updateInfos.push({
- type: updateTypes.UPDATE_THREAD_READ_STATUS,
+ type: updateTypes.UPDATE_THREAD,
id: uuid.v4(),
time,
- threadID,
- unread: true,
+ threadInfo: updatedThreadInfo,
});
}

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 4:54 AM (19 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2582999
Default Alt Text
D13241.diff (3 KB)

Event Timeline