mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 23:12:37 +01:00
Implement make moderator
This commit is contained in:
parent
e665f4adc3
commit
59628bd0c6
@ -1,4 +1,5 @@
|
|||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||||
import 'package:fluffychat/i18n/i18n.dart';
|
import 'package:fluffychat/i18n/i18n.dart';
|
||||||
import 'package:fluffychat/utils/app_route.dart';
|
import 'package:fluffychat/utils/app_route.dart';
|
||||||
import 'package:fluffychat/views/chat.dart';
|
import 'package:fluffychat/views/chat.dart';
|
||||||
@ -16,19 +17,34 @@ class ParticipantListItem extends StatelessWidget {
|
|||||||
final MatrixState matrix = Matrix.of(context);
|
final MatrixState matrix = Matrix.of(context);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "ban":
|
case "ban":
|
||||||
await matrix.tryRequestWithLoadingDialog(user.ban());
|
if (await SimpleDialogs(context).askConfirmation()) {
|
||||||
|
await matrix.tryRequestWithLoadingDialog(user.ban());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "unban":
|
case "unban":
|
||||||
await matrix.tryRequestWithLoadingDialog(user.unban());
|
if (await SimpleDialogs(context).askConfirmation()) {
|
||||||
|
await matrix.tryRequestWithLoadingDialog(user.unban());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "kick":
|
case "kick":
|
||||||
await matrix.tryRequestWithLoadingDialog(user.kick());
|
if (await SimpleDialogs(context).askConfirmation()) {
|
||||||
|
await matrix.tryRequestWithLoadingDialog(user.kick());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "admin":
|
case "admin":
|
||||||
await matrix.tryRequestWithLoadingDialog(user.setPower(100));
|
if (await SimpleDialogs(context).askConfirmation()) {
|
||||||
|
await matrix.tryRequestWithLoadingDialog(user.setPower(100));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "moderator":
|
||||||
|
if (await SimpleDialogs(context).askConfirmation()) {
|
||||||
|
await matrix.tryRequestWithLoadingDialog(user.setPower(50));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "user":
|
case "user":
|
||||||
await matrix.tryRequestWithLoadingDialog(user.setPower(0));
|
if (await SimpleDialogs(context).askConfirmation()) {
|
||||||
|
await matrix.tryRequestWithLoadingDialog(user.setPower(0));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "message":
|
case "message":
|
||||||
final String roomId = await user.startDirectChat();
|
final String roomId = await user.startDirectChat();
|
||||||
@ -54,6 +70,13 @@ class ParticipantListItem extends StatelessWidget {
|
|||||||
? I18n.of(context).admin
|
? I18n.of(context).admin
|
||||||
: user.powerLevel >= 50 ? I18n.of(context).moderator : "";
|
: user.powerLevel >= 50 ? I18n.of(context).moderator : "";
|
||||||
List<PopupMenuEntry<String>> items = <PopupMenuEntry<String>>[];
|
List<PopupMenuEntry<String>> items = <PopupMenuEntry<String>>[];
|
||||||
|
|
||||||
|
if (user.id != Matrix.of(context).client.userID) {
|
||||||
|
items.add(
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(I18n.of(context).sendAMessage), value: "message"),
|
||||||
|
);
|
||||||
|
}
|
||||||
if (user.canChangePowerLevel &&
|
if (user.canChangePowerLevel &&
|
||||||
user.room.ownPowerLevel == 100 &&
|
user.room.ownPowerLevel == 100 &&
|
||||||
user.powerLevel != 100) {
|
user.powerLevel != 100) {
|
||||||
@ -62,6 +85,14 @@ class ParticipantListItem extends StatelessWidget {
|
|||||||
child: Text(I18n.of(context).makeAnAdmin), value: "admin"),
|
child: Text(I18n.of(context).makeAnAdmin), value: "admin"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (user.canChangePowerLevel &&
|
||||||
|
user.room.ownPowerLevel >= 50 &&
|
||||||
|
user.powerLevel != 50) {
|
||||||
|
items.add(
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(I18n.of(context).makeAModerator), value: "moderator"),
|
||||||
|
);
|
||||||
|
}
|
||||||
if (user.canChangePowerLevel && user.powerLevel != 0) {
|
if (user.canChangePowerLevel && user.powerLevel != 0) {
|
||||||
items.add(
|
items.add(
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
@ -84,12 +115,6 @@ class ParticipantListItem extends StatelessWidget {
|
|||||||
child: Text(I18n.of(context).removeExile), value: "unban"),
|
child: Text(I18n.of(context).removeExile), value: "unban"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (user.id != Matrix.of(context).client.userID) {
|
|
||||||
items.add(
|
|
||||||
PopupMenuItem(
|
|
||||||
child: Text(I18n.of(context).sendAMessage), value: "message"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return PopupMenuButton(
|
return PopupMenuButton(
|
||||||
onSelected: (action) => participantAction(context, action),
|
onSelected: (action) => participantAction(context, action),
|
||||||
itemBuilder: (c) => items,
|
itemBuilder: (c) => items,
|
||||||
|
@ -394,6 +394,8 @@ class I18n {
|
|||||||
|
|
||||||
String get login => Intl.message("Login");
|
String get login => Intl.message("Login");
|
||||||
|
|
||||||
|
String get makeAModerator => Intl.message("Make a moderator");
|
||||||
|
|
||||||
String get makeAnAdmin => Intl.message("Make an admin");
|
String get makeAnAdmin => Intl.message("Make an admin");
|
||||||
|
|
||||||
String get makeSureTheIdentifierIsValid =>
|
String get makeSureTheIdentifierIsValid =>
|
||||||
|
Loading…
Reference in New Issue
Block a user