Skip to content

Commit cb11ab0

Browse files
committed
channel [nfc]: Guard ChannelDeleteEvent against unexpected sever behavior
See the motivation behind this: zulip#880 (comment)
1 parent 9ff0917 commit cb11ab0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/model/channel.dart

+13-6
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,19 @@ class ChannelStoreImpl with ChannelStore {
192192

193193
case ChannelDeleteEvent():
194194
for (final stream in event.streams) {
195-
assert(identical(streams[stream.streamId], streamsByName[stream.name]));
196-
assert(subscriptions[stream.streamId] == null
197-
|| identical(subscriptions[stream.streamId], streams[stream.streamId]));
198-
streams.remove(stream.streamId);
199-
streamsByName.remove(stream.name);
200-
subscriptions.remove(stream.streamId);
195+
final localStream = streams[stream.streamId];
196+
if (localStream == null) continue; // TODO(log)
197+
198+
final ZulipStream(:streamId, name: String streamName) = localStream;
199+
if (streamName != stream.name) {
200+
// TODO(log)
201+
}
202+
assert(identical(streams[streamId], streamsByName[streamName]));
203+
assert(subscriptions[streamId] == null
204+
|| identical(subscriptions[streamId], streams[streamId]));
205+
streams.remove(streamId);
206+
streamsByName.remove(streamName);
207+
subscriptions.remove(streamId);
201208
}
202209
}
203210
}

0 commit comments

Comments
 (0)