fix: type error in emote pack list in rooms with only non-default packs

If a room has emote packs, but none of them have an empty state key, we
insert 'null' to also add a default pack people can easily edit.
However, in that case we initialized the Map<String, Event?> variable
with a Map<String, Event>. As such assigning null will throw. Converting
manually with Map.of fixes that.

fixes #1138
This commit is contained in:
Nicolas Werner 2023-03-11 14:38:47 +01:00 committed by Nicolas Werner
parent ade164d824
commit 303ccbe965
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9

View File

@ -24,8 +24,11 @@ class MultipleEmotesSettingsView extends StatelessWidget {
body: StreamBuilder( body: StreamBuilder(
stream: room.onUpdate.stream, stream: room.onUpdate.stream,
builder: (context, snapshot) { builder: (context, snapshot) {
final Map<String, Event?> packs = final packStateEvents = room.states['im.ponies.room_emotes'];
room.states['im.ponies.room_emotes'] ?? <String, Event>{}; // we need to manually convert the map using Map.of, otherwise assigning null will throw a type error.
final Map<String, Event?> packs = packStateEvents != null
? Map<String, Event?>.of(packStateEvents)
: <String, Event?>{};
if (!packs.containsKey('')) { if (!packs.containsKey('')) {
packs[''] = null; packs[''] = null;
} }