Page MenuHomePhabricator

D10271.id34449.diff
No OneTemporary

D10271.id34449.diff

diff --git a/lib/shared/updates/update-thread-read-status-spec.js b/lib/shared/updates/update-thread-read-status-spec.js
--- a/lib/shared/updates/update-thread-read-status-spec.js
+++ b/lib/shared/updates/update-thread-read-status-spec.js
@@ -4,8 +4,8 @@
import type { UpdateSpec } from './update-spec.js';
import type {
- LegacyRawThreadInfo,
- LegacyRawThreadInfos,
+ RawThreadInfo,
+ RawThreadInfos,
} from '../../types/thread-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
import type {
@@ -21,33 +21,57 @@
ThreadReadStatusUpdateData,
> = Object.freeze({
generateOpsForThreadUpdates(
- storeThreadInfos: LegacyRawThreadInfos,
+ storeThreadInfos: RawThreadInfos,
update: ThreadReadStatusUpdateInfo,
) {
- const storeThreadInfo: ?LegacyRawThreadInfo =
- storeThreadInfos[update.threadID];
if (
- !storeThreadInfo ||
- storeThreadInfo.currentUser.unread === update.unread
+ !storeThreadInfos[update.threadID] ||
+ storeThreadInfos[update.threadID].currentUser.unread === update.unread
) {
return null;
}
- const updatedThread = {
- ...storeThreadInfo,
- currentUser: {
- ...storeThreadInfo.currentUser,
+ const storeThreadInfo: RawThreadInfo = storeThreadInfos[update.threadID];
+ // TODO (atul): Try to get rid of this ridiculous branching.
+ if (storeThreadInfo.minimallyEncoded) {
+ const currentUser = storeThreadInfo.currentUser;
+ const updatedUser = {
+ role: currentUser.role,
+ subscription: currentUser.subscription,
unread: update.unread,
- },
- };
- return [
- {
- type: 'replace',
- payload: {
- id: update.threadID,
- threadInfo: updatedThread,
+ minimallyEncoded: true,
+ permissions: currentUser.permissions,
+ };
+ const updatedThread = {
+ ...storeThreadInfo,
+ currentUser: updatedUser,
+ };
+ return [
+ {
+ type: 'replace',
+ payload: {
+ id: update.threadID,
+ threadInfo: updatedThread,
+ },
+ },
+ ];
+ } else {
+ const updatedThread = {
+ ...storeThreadInfo,
+ currentUser: {
+ ...storeThreadInfo.currentUser,
+ unread: update.unread,
},
- },
- ];
+ };
+ return [
+ {
+ type: 'replace',
+ payload: {
+ id: update.threadID,
+ threadInfo: updatedThread,
+ },
+ },
+ ];
+ }
},
rawUpdateInfoFromRow(row: Object) {
const { threadID, unread } = JSON.parse(row.content);

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 10:41 PM (20 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2433433
Default Alt Text
D10271.id34449.diff (2 KB)

Event Timeline