Skip to content

Commit a5aeb4c

Browse files
committed
modelTypes: Move .subject_links from Message to StreamMessage.
The last field we need to do this for! :)
1 parent 17b92c9 commit a5aeb4c

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

src/__tests__/lib/exampleData.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ const messagePropertiesBase = deepFreeze({
296296
is_me_message: false,
297297
// last_edit_timestamp omitted
298298
reactions: [],
299-
subject_links: [],
300299
submessages: [],
301300
});
302301

@@ -393,6 +392,7 @@ export const streamMessage = (args?: {|
393392
content_type: 'text/markdown',
394393
id: randMessageId(),
395394
subject: 'example topic',
395+
subject_links: [],
396396
timestamp: 1556579727,
397397
type: 'stream',
398398
};

src/api/modelTypes.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -508,18 +508,11 @@ type MessageBase = $ReadOnly<{|
508508

509509
/** Deprecated; a server implementation detail not useful in a client. */
510510
// recipient_id: number,
511-
512-
//
513-
// Properties that behave differently for stream vs. private messages.
514-
// TODO: Move all these to `PmMessage` and `StreamMessage`.
515-
516-
subject_links: $ReadOnlyArray<string>,
517511
|}>;
518512

519513
export type PmMessage = $ReadOnly<{|
520514
...MessageBase,
521515

522-
// TODO: Put PM-message fields here.
523516
type: 'private',
524517

525518
// Notes from studying the server code:
@@ -556,7 +549,6 @@ export type PmMessage = $ReadOnly<{|
556549
export type StreamMessage = $ReadOnly<{|
557550
...MessageBase,
558551

559-
// TODO: Put stream-message fields here.
560552
type: 'stream',
561553

562554
/**
@@ -569,6 +561,7 @@ export type StreamMessage = $ReadOnly<{|
569561
stream_id: number,
570562

571563
subject: string,
564+
subject_links: $ReadOnlyArray<string>,
572565
|}>;
573566

574567
/**

src/message/messagesReducer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ export default (state: MessagesState = initialState, action: Action): MessagesSt
140140
const messageWithNewCommonFields: M = {
141141
...(oldMessage: M),
142142
content: action.rendered_content || oldMessage.content,
143-
subject_links: action.subject_links || oldMessage.subject_links,
144143
edit_history: [
145144
action.orig_rendered_content
146145
? action.orig_subject !== undefined
@@ -170,7 +169,8 @@ export default (state: MessagesState = initialState, action: Action): MessagesSt
170169
return messageWithNewCommonFields.type === 'stream'
171170
? {
172171
...messageWithNewCommonFields,
173-
subject: action.subject || oldMessage.subject,
172+
subject: action.subject || messageWithNewCommonFields.subject,
173+
subject_links: action.subject_links || messageWithNewCommonFields.subject_links,
174174
}
175175
: {
176176
...messageWithNewCommonFields,

0 commit comments

Comments
 (0)