diff --git a/lib/src/room.dart b/lib/src/room.dart index ede90143..7fbd1447 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -482,6 +482,18 @@ class Room { tag, ); + // Tag is part of client-to-server-API, so it uses strict parsing. + // For roomAccountData, permissive parsing is more suitable, + // so it is implemented here. + static Tag _tryTagFromJson(Object o) { + if (o is Map) { + return Tag( + order: o.tryGet('order').toDouble(), + additionalProperties: Map.from(o)..remove('order')); + } + return Tag(); + } + /// Returns all tags for this room. Map get tags { if (roomAccountData['m.tag'] == null || @@ -489,7 +501,7 @@ class Room { return {}; } final tags = (roomAccountData['m.tag'].content['tags'] as Map) - .map((k, v) => MapEntry(k, Tag.fromJson(v))); + .map((k, v) => MapEntry(k, _tryTagFromJson(v))); tags.removeWhere((k, v) => !TagType.isValid(k)); return tags; }