From f5b1c5fc5f4771d1dff2cda25c95a0e490d33aa9 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Tue, 22 Dec 2020 09:48:37 +0100 Subject: [PATCH] fix: Don't assume a power level of a person is an int --- lib/src/room.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index f89d1a72..204d046c 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -31,6 +31,7 @@ import 'timeline.dart'; import 'user.dart'; import 'utils/event_update.dart'; import '../matrix_api/utils/logs.dart'; +import '../matrix_api/utils/try_get_map_extension.dart'; import 'utils/markdown.dart'; import 'utils/matrix_file.dart'; import 'utils/matrix_localizations.dart'; @@ -1283,8 +1284,10 @@ class Room { if (powerLevelState.content['users_default'] is int) { powerLevel = powerLevelState.content['users_default']; } - if (powerLevelState.content['users'] is Map && - powerLevelState.content['users'][userId] != null) { + if (powerLevelState.content + .tryGet>('users') + ?.tryGet(userId) != + null) { powerLevel = powerLevelState.content['users'][userId]; } return powerLevel;