Parse power levels if they're strings

parent 3138af48
......@@ -47,15 +47,17 @@ class PowerLevelsChangeEvent extends StateEvent {
}
final Map<Type, int> events = jsonEvents.map((eventType, powerLevel) {
powerLevel = powerLevel is String ? int.parse(powerLevel) : powerLevel;
return MapEntry<Type, int>(Event.typeOf(eventType), powerLevel);
}).cast<Type, int>();
final int stateDefault = content['state_default'] ?? 50;
final int userDefault = content['users_default'] ?? 0;
final Map<UserId, int> users = content['users']
.map((userId, powerLevel) => MapEntry(UserId(userId), powerLevel))
.cast<UserId, int>();
final Map<UserId, int> users = content['users'].map((userId, powerLevel) {
powerLevel = powerLevel is String ? int.parse(powerLevel) : powerLevel;
return MapEntry(UserId(userId), powerLevel);
}).cast<UserId, int>();
final roomNotifications = json.containsKey('notifications')
? json['notifications']['room'] ?? 50
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment