Skip to content

Commit 020bfcb

Browse files
PIG208gnprice
authored andcommitted
message: Expect the absence of newTopic for certain moves.
As noted in: #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]>
1 parent ba952c3 commit 020bfcb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/model/message.dart

+5-4
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ class MessageStoreImpl with MessageStore {
167167
return;
168168
}
169169

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

181182
if (newStreamId == null
182-
&& MessageEditState.topicMoveWasResolveOrUnresolve(origTopic, newTopic)) {
183+
&& MessageEditState.topicMoveWasResolveOrUnresolve(origTopic, newTopic!)) {
183184
// The topic was only resolved/unresolved.
184185
// No change to the messages' editState.
185186
return;

0 commit comments

Comments
 (0)