Skip to content

Commit 9e0da39

Browse files
committed
model: Set message.displayRecipient to null on stream move.
StreamMessage.displayRecipient no longer carries the up-to-date display name of the stream when the message has been moved to another stream. We invalidate it by setting it to null. The only time StreamMessage.displayRecipient is useful is when we don't have data on that stream. This is the reason why we don't go ahead and lookup the stream store when such a stream move happen, because the stream store likely will not have that information if we ever need to use displayRecipient as the fallback. Signed-off-by: Zixuan James Li <[email protected]>
1 parent ce741cb commit 9e0da39

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/model/message.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ class MessageStoreImpl with MessageStore {
192192

193193
if (newStreamId != null) {
194194
message.streamId = newStreamId;
195-
// TODO update [StreamMessage.displayRecipient]; doesn't usually
196-
// matter, because we only consult it when the stream is unknown
195+
message.displayRecipient = null;
197196
}
198197

199198
message.topic = newTopic;

test/model/message_test.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,17 @@ void main() {
295295
});
296296

297297
test('message topic moved update', () async {
298+
final originalDisplayRecipient = message.displayRecipient!;
298299
await sendEvent(message,
299300
eg.updateMessageMoveEvent([message, otherMessage],
300301
origTopic: 'old topic',
301302
newTopic: 'new topic'),
302303
notifiedCount: 2,
303304
);
304-
check(store).messages.values.every(((message) => message.editState.equals(MessageEditState.moved)));
305+
check(store).messages.values.every(((message) =>
306+
message.isA<StreamMessage>()
307+
..editState.equals(MessageEditState.moved)
308+
..displayRecipient.equals(originalDisplayRecipient)));
305309
});
306310

307311
test('message topic resolved update', () async {
@@ -352,7 +356,10 @@ void main() {
352356
newStreamId: 20),
353357
notifiedCount: 2,
354358
);
355-
check(store).messages.values.every(((message) => message.editState.equals(MessageEditState.moved)));
359+
check(store).messages.values.every(((message) =>
360+
message.isA<StreamMessage>()
361+
..editState.equals(MessageEditState.moved)
362+
..displayRecipient.equals(null)));
356363
});
357364

358365
test('message is both moved and updated', () async {

0 commit comments

Comments
 (0)