Skip to content

Commit

Permalink
model: Expect the absence of newTopic for certain moves.
Browse files Browse the repository at this point in the history
As noted in:

zulip#787 (review)

There is an discrepency between the API docs and the actual server
behavior on the presence of the "new_topic" field on the update message
event. While it was claimed to be always present when a move occurs, it
is actually not the case when the message moves across channels without
chaning its topic.

Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Aug 9, 2024
1 parent f0b3596 commit 3c0b4f9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/model/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ class MessageStoreImpl with MessageStore {
return;
}

if (newTopic == null) {
// The `subject` field (aka newTopic) is documented to be present on moves.
assert(debugLog('Malformed UpdateMessageEvent: move but no newTopic')); // TODO(log)
if (newStreamId == null && newTopic == null) {
// If neither the channel nor topic name changed, nothing moved.
// In that case `orig_subject` (aka origTopic) should have been null.
assert(debugLog('Malformed UpdateMessageEvent: move but no newStreamId or newTopic')); // TODO(log)
return;
}
if (origStreamId == null) {
Expand All @@ -179,7 +180,7 @@ class MessageStoreImpl with MessageStore {
}

if (newStreamId == null
&& MessageEditState.topicMoveWasResolveOrUnresolve(origTopic, newTopic)) {
&& MessageEditState.topicMoveWasResolveOrUnresolve(origTopic, newTopic!)) {
// The topic was only resolved/unresolved.
// No change to the messages' editState.
return;
Expand Down

0 comments on commit 3c0b4f9

Please sign in to comment.