Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3367846
D9538.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D9538.diff
View Options
diff --git a/keyserver/src/fetchers/message-fetchers.js b/keyserver/src/fetchers/message-fetchers.js
--- a/keyserver/src/fetchers/message-fetchers.js
+++ b/keyserver/src/fetchers/message-fetchers.js
@@ -7,6 +7,7 @@
shimUnsupportedRawMessageInfos,
isInvalidSidebarSource,
isUnableToBeRenderedIndependently,
+ isInvalidPinSource,
} from 'lib/shared/message-utils.js';
import { messageSpecs } from 'lib/shared/messages/message-specs.js';
import { getNotifCollapseKey } from 'lib/shared/notif-utils.js';
@@ -745,11 +746,21 @@
for (const message of messages) {
let { rawMessageInfo } = message;
- invariant(
- !isInvalidSidebarSource(rawMessageInfo),
- 'SIDEBAR_SOURCE or TOGGLE_PIN should not point to a ' +
- 'SIDEBAR_SOURCE, REACTION, EDIT_MESSAGE or TOGGLE_PIN',
- );
+
+ if (rawMessageInfo.type === messageTypes.SIDEBAR_SOURCE) {
+ invariant(
+ !isInvalidSidebarSource(rawMessageInfo),
+ 'SIDEBAR_SOURCE should not point to a ' +
+ 'SIDEBAR_SOURCE, REACTION, EDIT_MESSAGE or TOGGLE_PIN',
+ );
+ }
+ if (rawMessageInfo.type === messageTypes.TOGGLE_PIN) {
+ invariant(
+ !isInvalidPinSource(rawMessageInfo),
+ 'TOGGLE_PIN should not point to a non-composable message type',
+ );
+ }
+
if (rawMessageInfo.id) {
const editedContent = edits.get(rawMessageInfo.id);
if (editedContent && rawMessageInfo.type === messageTypes.TEXT) {
@@ -759,6 +770,11 @@
};
}
invariant(rawMessageInfo.id, 'rawMessageInfo.id should not be null');
+ // Flow doesn't refine the types if we don't explicitly invariant on
+ // or check against all of the unexpected message types, and that list
+ // can both get long and generally defeats the purpose of moving the
+ // logic into message specs to have one 'single source of truth'.
+ // $FlowFixMe
messagesByID.set(rawMessageInfo.id, rawMessageInfo);
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 4:42 PM (22 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585504
Default Alt Text
D9538.diff (1 KB)
Attached To
Mode
D9538: [lib] Refactor fetchDerivedMessages to call isInvalidSidebarSource or isInvalidPinSource
Attached
Detach File
Event Timeline
Log In to Comment