fix for bugs with locked room icons
This commit is contained in:
parent
bfdacbf3ad
commit
8bef7b2e2b
5 changed files with 11 additions and 8 deletions
|
|
@ -78,8 +78,7 @@ class ChatEventList extends StatelessWidget {
|
|||
|
||||
// #Pangea
|
||||
if (i == 1) {
|
||||
return (controller.room.locked ?? false) &&
|
||||
!controller.room.isRoomAdmin
|
||||
return (controller.room.locked) && !controller.room.isRoomAdmin
|
||||
? const LockedChatMessage()
|
||||
: const SizedBox.shrink();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -556,12 +556,12 @@ class ChatDetailsView extends StatelessWidget {
|
|||
Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor: iconColor,
|
||||
child: Icon(
|
||||
room.locked ?? false
|
||||
room.locked
|
||||
? Icons.lock_outlined
|
||||
: Icons.no_encryption_outlined,
|
||||
),
|
||||
),
|
||||
value: room.locked ?? false,
|
||||
value: room.locked,
|
||||
onChanged: (value) => showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => value
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ class ChatListItem extends StatelessWidget {
|
|||
),
|
||||
const SizedBox(width: 8),
|
||||
// #Pangea
|
||||
if (room.locked ?? false)
|
||||
if (room.locked)
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(right: 4.0),
|
||||
child: Icon(
|
||||
|
|
|
|||
|
|
@ -923,17 +923,17 @@ extension PangeaRoom on Room {
|
|||
?.content
|
||||
.tryGet<int>('events_default');
|
||||
|
||||
bool? get locked {
|
||||
bool get locked {
|
||||
if (isDirectChat) return false;
|
||||
if (!isSpace) {
|
||||
if (eventsDefaultPowerLevel == null) return null;
|
||||
if (eventsDefaultPowerLevel == null) return false;
|
||||
return (eventsDefaultPowerLevel ?? 0) >=
|
||||
ClassDefaultValues.powerLevelOfAdmin;
|
||||
}
|
||||
for (final child in spaceChildren) {
|
||||
if (child.roomId == null) continue;
|
||||
final Room? room = client.getRoomById(child.roomId!);
|
||||
if (room?.locked == false && (room?.canChangePowerLevel ?? false)) {
|
||||
if (room?.locked == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,11 @@ Future<void> lockChat(Room room, Client client) async {
|
|||
final Map<String, dynamic> powerLevelsContent = Map<String, dynamic>.from(
|
||||
room.getState(EventTypes.RoomPowerLevels)!.content,
|
||||
);
|
||||
|
||||
powerLevelsContent['events_default'] = 100;
|
||||
if (!powerLevelsContent.containsKey('events')) {
|
||||
powerLevelsContent['events'] = Map<String, dynamic>.from({});
|
||||
}
|
||||
powerLevelsContent['events'][EventTypes.spaceChild] = 100;
|
||||
|
||||
await room.client.setRoomStateWithKey(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue