Merge pull request #48 from pangeachat/power-level-fix

fix for null check error in setclasspowerlevels
This commit is contained in:
ggurdin 2024-01-22 13:46:59 -05:00 committed by GitHub
commit a6c781b1a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -827,22 +827,23 @@ extension PangeaRoom on Room {
if (ownPowerLevel < ClassDefaultValues.powerLevelOfAdmin) {
return;
}
final currentPower = getState(EventTypes.RoomPowerLevels);
final Event? currentPower = getState(EventTypes.RoomPowerLevels);
final Map<String, dynamic>? currentPowerContent =
currentPower!.content["events"] as Map<String, dynamic>?;
currentPower?.content["events"] as Map<String, dynamic>?;
final spaceChildPower = currentPowerContent?[EventTypes.spaceChild];
final studentAnalyticsPower =
currentPowerContent?[PangeaEventTypes.studentAnalyticsSummary];
if (spaceChildPower == null || studentAnalyticsPower == null) {
currentPowerContent!["events"][EventTypes.spaceChild] = 0;
if ((spaceChildPower == null || studentAnalyticsPower == null) &&
currentPowerContent != null) {
currentPowerContent["events"][EventTypes.spaceChild] = 0;
currentPowerContent["events"]
[PangeaEventTypes.studentAnalyticsSummary] = 0;
await client.setRoomStateWithKey(
id,
EventTypes.RoomPowerLevels,
currentPower.stateKey ?? "",
currentPower?.stateKey ?? "",
currentPowerContent,
);
}