chore: add new default power levels (#2855)
* chore: add new default power levels * chore: update permissions copy
This commit is contained in:
parent
871c9303f8
commit
c45415749b
8 changed files with 170 additions and 93 deletions
|
|
@ -4944,5 +4944,13 @@
|
|||
"searchChats": "Search chats",
|
||||
"selectChats": "Select chats",
|
||||
"selectChatToStart": "Complete! Select a chat to start",
|
||||
"displayNavigationRail": "Show navigation rail on mobile"
|
||||
"configureSpace": "Configure space",
|
||||
"pinMessages": "Pin messages",
|
||||
"setJoinRules": "Set join rules",
|
||||
"displayNavigationRail": "Show navigation rail on mobile",
|
||||
"changeGeneralSettings": "Change general settings",
|
||||
"inviteOtherUsersToRoom": "Invite other users",
|
||||
"changeTheNameOfTheSpace": "Change the name of the space",
|
||||
"changeTheDescription": "Change the description",
|
||||
"changeThePermissions": "Change the permissions"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ class ChatPermissionsSettingsView extends StatelessWidget {
|
|||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: const Center(child: BackButton()),
|
||||
title: Text(L10n.of(context).chatPermissions),
|
||||
// #Pangea
|
||||
// title: Text(L10n.of(context).chatPermissions),
|
||||
title: Text(L10n.of(context).permissions),
|
||||
// Pangea#
|
||||
),
|
||||
body: MaxWidthBody(
|
||||
child: StreamBuilder(
|
||||
|
|
@ -36,28 +39,11 @@ class ChatPermissionsSettingsView extends StatelessWidget {
|
|||
final powerLevelsContent = Map<String, Object?>.from(
|
||||
room.getState(EventTypes.RoomPowerLevels)?.content ?? {},
|
||||
);
|
||||
final powerLevels =
|
||||
Map<String, dynamic>.from(powerLevelsContent) // #Pangea
|
||||
// ..removeWhere((k, v) => v is! int);
|
||||
..removeWhere(
|
||||
(k, v) =>
|
||||
v is! int ||
|
||||
k.equals("m.call.invite") ||
|
||||
k.equals("historical") ||
|
||||
k.equals("state_default"),
|
||||
);
|
||||
// Pangea#
|
||||
final powerLevels = Map<String, dynamic>.from(powerLevelsContent)
|
||||
..removeWhere((k, v) => v is! int);
|
||||
final eventsPowerLevels = Map<String, int?>.from(
|
||||
powerLevelsContent.tryGetMap<String, int?>('events') ?? {},
|
||||
// #Pangea
|
||||
)..removeWhere(
|
||||
(k, v) =>
|
||||
v is! int ||
|
||||
k.equals("pangea.usranalytics") ||
|
||||
k.equals(EventTypes.RoomPowerLevels),
|
||||
);
|
||||
// )..removeWhere((k, v) => v is! int);
|
||||
// Pangea#
|
||||
)..removeWhere((k, v) => v is! int);
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
|
|
@ -69,7 +55,10 @@ class ChatPermissionsSettingsView extends StatelessWidget {
|
|||
Divider(color: theme.dividerColor),
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context).chatPermissions,
|
||||
// #Pangea
|
||||
// L10n.of(context).chatPermissions,
|
||||
L10n.of(context).permissions,
|
||||
// Pangea#
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
@ -90,48 +79,57 @@ class ChatPermissionsSettingsView extends StatelessWidget {
|
|||
newLevel: level,
|
||||
),
|
||||
canEdit: room.canChangePowerLevel,
|
||||
// #Pangea
|
||||
room: room,
|
||||
// Pangea#
|
||||
),
|
||||
// #Pangea
|
||||
// Divider(color: theme.dividerColor),
|
||||
// ListTile(
|
||||
// title: Text(
|
||||
// L10n.of(context).notifications,
|
||||
// style: TextStyle(
|
||||
// color: theme.colorScheme.primary,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Builder(
|
||||
// builder: (context) {
|
||||
// const key = 'rooms';
|
||||
// final value = powerLevelsContent
|
||||
// .containsKey('notifications')
|
||||
// ? powerLevelsContent
|
||||
// .tryGetMap<String, Object?>('notifications')
|
||||
// ?.tryGet<int>('rooms') ??
|
||||
// 0
|
||||
// : 0;
|
||||
// return PermissionsListTile(
|
||||
// permissionKey: key,
|
||||
// permission: value,
|
||||
// category: 'notifications',
|
||||
// canEdit: room.canChangePowerLevel,
|
||||
// onChanged: (level) => controller.editPowerLevel(
|
||||
// context,
|
||||
// key,
|
||||
// value,
|
||||
// newLevel: level,
|
||||
// category: 'notifications',
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// Pangea#
|
||||
Divider(color: theme.dividerColor),
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context).configureChat,
|
||||
L10n.of(context).notifications,
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
const key = 'rooms';
|
||||
final value = powerLevelsContent
|
||||
.containsKey('notifications')
|
||||
? powerLevelsContent
|
||||
.tryGetMap<String, Object?>('notifications')
|
||||
?.tryGet<int>('rooms') ??
|
||||
0
|
||||
: 0;
|
||||
return PermissionsListTile(
|
||||
permissionKey: key,
|
||||
permission: value,
|
||||
category: 'notifications',
|
||||
canEdit: room.canChangePowerLevel,
|
||||
onChanged: (level) => controller.editPowerLevel(
|
||||
context,
|
||||
key,
|
||||
value,
|
||||
newLevel: level,
|
||||
category: 'notifications',
|
||||
),
|
||||
// #Pangea
|
||||
room: room,
|
||||
// Pangea#
|
||||
);
|
||||
},
|
||||
),
|
||||
Divider(color: theme.dividerColor),
|
||||
ListTile(
|
||||
title: Text(
|
||||
// #Pangea
|
||||
// L10n.of(context).configureChat,
|
||||
room.isSpace
|
||||
? L10n.of(context).configureSpace
|
||||
: L10n.of(context).configureChat,
|
||||
// Pangea#
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
@ -151,6 +149,9 @@ class ChatPermissionsSettingsView extends StatelessWidget {
|
|||
newLevel: level,
|
||||
category: 'events',
|
||||
),
|
||||
// #Pangea
|
||||
room: room,
|
||||
// Pangea#
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ class PermissionsListTile extends StatelessWidget {
|
|||
final String? category;
|
||||
final void Function(int? level)? onChanged;
|
||||
final bool canEdit;
|
||||
// #Pangea
|
||||
final Room room;
|
||||
// Pangea#
|
||||
|
||||
const PermissionsListTile({
|
||||
super.key,
|
||||
|
|
@ -19,6 +22,9 @@ class PermissionsListTile extends StatelessWidget {
|
|||
this.category,
|
||||
required this.onChanged,
|
||||
required this.canEdit,
|
||||
// #Pangea
|
||||
required this.room,
|
||||
// Pangea#
|
||||
});
|
||||
|
||||
String getLocalizedPowerLevelString(BuildContext context) {
|
||||
|
|
@ -29,15 +35,27 @@ class PermissionsListTile extends StatelessWidget {
|
|||
case 'events_default':
|
||||
return L10n.of(context).sendMessages;
|
||||
case 'state_default':
|
||||
return L10n.of(context).changeGeneralChatSettings;
|
||||
// #Pangea
|
||||
// return L10n.of(context).changeGeneralChatSettings;
|
||||
return L10n.of(context).changeGeneralSettings;
|
||||
// Pangea#
|
||||
case 'ban':
|
||||
return L10n.of(context).banFromChat;
|
||||
// #Pangea
|
||||
// return L10n.of(context).banFromChat;
|
||||
return L10n.of(context).ban;
|
||||
// Pangea#
|
||||
case 'kick':
|
||||
return L10n.of(context).kickFromChat;
|
||||
// #Pangea
|
||||
// return L10n.of(context).kickFromChat;
|
||||
return L10n.of(context).kick;
|
||||
// Pangea#
|
||||
case 'redact':
|
||||
return L10n.of(context).deleteMessage;
|
||||
case 'invite':
|
||||
return L10n.of(context).inviteOtherUsers;
|
||||
// #Pangea
|
||||
// return L10n.of(context).inviteOtherUsers;
|
||||
return L10n.of(context).inviteOtherUsersToRoom;
|
||||
// Pangea#
|
||||
}
|
||||
} else if (category == 'notifications') {
|
||||
switch (permissionKey) {
|
||||
|
|
@ -49,12 +67,20 @@ class PermissionsListTile extends StatelessWidget {
|
|||
case EventTypes.RoomName:
|
||||
// #Pangea
|
||||
// return L10n.of(context).changeTheNameOfTheGroup;
|
||||
return L10n.of(context).changeTheNameOfTheChat;
|
||||
return room.isSpace
|
||||
? L10n.of(context).changeTheNameOfTheSpace
|
||||
: L10n.of(context).changeTheNameOfTheChat;
|
||||
// Pangea#
|
||||
case EventTypes.RoomTopic:
|
||||
return L10n.of(context).changeTheDescriptionOfTheGroup;
|
||||
// #Pangea
|
||||
// return L10n.of(context).changeTheDescriptionOfTheGroup;
|
||||
return L10n.of(context).changeTheDescription;
|
||||
// Pangea#
|
||||
case EventTypes.RoomPowerLevels:
|
||||
return L10n.of(context).changeTheChatPermissions;
|
||||
// #Pangea
|
||||
// return L10n.of(context).changeTheChatPermissions;
|
||||
return L10n.of(context).changeThePermissions;
|
||||
// Pangea#
|
||||
case EventTypes.HistoryVisibility:
|
||||
return L10n.of(context).changeTheVisibilityOfChatHistory;
|
||||
case EventTypes.RoomCanonicalAlias:
|
||||
|
|
@ -70,6 +96,10 @@ class PermissionsListTile extends StatelessWidget {
|
|||
// #Pangea
|
||||
case EventTypes.SpaceChild:
|
||||
return L10n.of(context).spaceChildPermission;
|
||||
case EventTypes.RoomPinnedEvents:
|
||||
return L10n.of(context).pinMessages;
|
||||
case EventTypes.RoomJoinRules:
|
||||
return L10n.of(context).setJoinRules;
|
||||
// Pangea#
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import 'package:fluffychat/config/app_config.dart';
|
|||
import 'package:fluffychat/pangea/activity_planner/activity_plan_model.dart';
|
||||
import 'package:fluffychat/pangea/activity_planner/activity_planner_builder.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/chat/constants/default_power_level.dart';
|
||||
import 'package:fluffychat/pangea/chat_settings/constants/bot_mode.dart';
|
||||
import 'package:fluffychat/pangea/chat_settings/models/bot_options_model.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
|
|
@ -178,6 +179,13 @@ class ActivityRoomSelectionState extends State<ActivityRoomSelection> {
|
|||
preset: CreateRoomPreset.trustedPrivateChat,
|
||||
initialState: [
|
||||
BotOptionsModel(mode: BotMode.directChat).toStateEvent,
|
||||
StateEvent(
|
||||
type: EventTypes.RoomPowerLevels,
|
||||
stateKey: '',
|
||||
content: defaultPowerLevels(
|
||||
Matrix.of(context).client.userID!,
|
||||
),
|
||||
),
|
||||
if (avatar != null && avatarUrl != null)
|
||||
StateEvent(
|
||||
type: EventTypes.RoomAvatar,
|
||||
|
|
|
|||
|
|
@ -1,32 +1,60 @@
|
|||
Map<String, dynamic> defaultPowerLevels(String userID) => {
|
||||
"ban": 50,
|
||||
"kick": 50,
|
||||
"invite": 50,
|
||||
"redact": 50,
|
||||
"events": {
|
||||
"m.room.avatar": 50,
|
||||
"m.room.canonical_alias": 50,
|
||||
"m.room.encryption": 100,
|
||||
"m.room.history_visibility": 100,
|
||||
"m.room.name": 50,
|
||||
"m.room.power_levels": 100,
|
||||
"m.room.server_acl": 100,
|
||||
"m.room.tombstone": 100,
|
||||
"m.room.pinned_events": 50,
|
||||
},
|
||||
"events_default": 0,
|
||||
"state_default": 50,
|
||||
"users": {
|
||||
userID: 100,
|
||||
},
|
||||
"users_default": 0,
|
||||
"notifications": {
|
||||
"room": 50,
|
||||
},
|
||||
};
|
||||
|
||||
Map<String, dynamic> restrictedPowerLevels(String userID) => {
|
||||
"events_default": 50,
|
||||
"ban": 50,
|
||||
"kick": 50,
|
||||
"invite": 50,
|
||||
"redact": 50,
|
||||
"events": {
|
||||
"m.room.avatar": 50,
|
||||
"m.room.canonical_alias": 50,
|
||||
"m.room.encryption": 100,
|
||||
"m.room.history_visibility": 100,
|
||||
"m.room.name": 50,
|
||||
"m.room.power_levels": 100,
|
||||
"m.room.server_acl": 100,
|
||||
"m.room.tombstone": 100,
|
||||
"m.room.pinned_events": 50,
|
||||
},
|
||||
"events_default": 50,
|
||||
"state_default": 50,
|
||||
"users": {
|
||||
userID: 100,
|
||||
},
|
||||
"users_default": 0,
|
||||
"notifications": {
|
||||
"room": 50,
|
||||
},
|
||||
};
|
||||
|
||||
Map<String, dynamic> defaultSpacePowerLevels(String userID) => {
|
||||
"ban": 50,
|
||||
"kick": 50,
|
||||
"invite": 50,
|
||||
"redact": 50,
|
||||
"events": {
|
||||
"m.room.power_levels": 100,
|
||||
"m.room.join_rules": 100,
|
||||
"m.space.child": 50,
|
||||
},
|
||||
"events_default": 0,
|
||||
"state_default": 50,
|
||||
"users": {
|
||||
userID: 100,
|
||||
},
|
||||
"users_default": 0,
|
||||
"notifications": {
|
||||
"room": 50,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
|||
import 'package:fluffychat/pangea/analytics_misc/get_analytics_controller.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/put_analytics_controller.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/chat/constants/default_power_level.dart';
|
||||
import 'package:fluffychat/pangea/chat_settings/constants/bot_mode.dart';
|
||||
import 'package:fluffychat/pangea/chat_settings/models/bot_options_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/contextual_definition_controller.dart';
|
||||
|
|
@ -268,6 +269,13 @@ class PangeaController {
|
|||
preset: CreateRoomPreset.trustedPrivateChat,
|
||||
initialState: [
|
||||
BotOptionsModel(mode: BotMode.directChat).toStateEvent,
|
||||
StateEvent(
|
||||
type: EventTypes.RoomPowerLevels,
|
||||
stateKey: '',
|
||||
content: defaultPowerLevels(
|
||||
matrixState.client.userID!,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class RepresentationEvent {
|
|||
if (tokenEvents.isEmpty) return null;
|
||||
|
||||
if (tokenEvents.length > 1) {
|
||||
debugger(when: kDebugMode);
|
||||
// debugger(when: kDebugMode);
|
||||
Sentry.addBreadcrumb(
|
||||
Breadcrumb(
|
||||
message:
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ extension SpacesClientExtension on Client {
|
|||
powerLevelContentOverride: {'events_default': 100},
|
||||
initialState: [
|
||||
..._spaceInitialState(
|
||||
userID!,
|
||||
joinCode,
|
||||
joinRules: joinRules,
|
||||
),
|
||||
|
|
@ -123,6 +124,7 @@ extension SpacesClientExtension on Client {
|
|||
}
|
||||
|
||||
List<StateEvent> _spaceInitialState(
|
||||
String userID,
|
||||
String joinCode, {
|
||||
required JoinRules joinRules,
|
||||
}) {
|
||||
|
|
@ -130,15 +132,7 @@ extension SpacesClientExtension on Client {
|
|||
StateEvent(
|
||||
type: EventTypes.RoomPowerLevels,
|
||||
stateKey: '',
|
||||
content: {
|
||||
'events': {
|
||||
EventTypes.SpaceChild: 50,
|
||||
},
|
||||
'users_default': 0,
|
||||
'users': {
|
||||
userID: SpaceConstants.powerLevelOfAdmin,
|
||||
},
|
||||
},
|
||||
content: defaultSpacePowerLevels(userID),
|
||||
),
|
||||
StateEvent(
|
||||
type: EventTypes.RoomJoinRules,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue