forked from Nexus/nexus
fix some power level checks, fixes #19
This commit is contained in:
parent
7d8b267986
commit
e310f0f60e
2 changed files with 136 additions and 115 deletions
|
|
@ -91,7 +91,9 @@ class ChatBox extends HookConsumerWidget {
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: canSendMessages
|
||||||
|
? [
|
||||||
EmojiPickerButton(
|
EmojiPickerButton(
|
||||||
context: context,
|
context: context,
|
||||||
onSelection: (_) => node?.requestFocus(),
|
onSelection: (_) => node?.requestFocus(),
|
||||||
|
|
@ -138,16 +140,17 @@ class ChatBox extends HookConsumerWidget {
|
||||||
triggerCharacter.value = newTriggerCharacter;
|
triggerCharacter.value = newTriggerCharacter;
|
||||||
query.value = newQuery;
|
query.value = newQuery;
|
||||||
},
|
},
|
||||||
triggerCharacterAndStyles: {"@": style, "#": style},
|
triggerCharacterAndStyles: {
|
||||||
|
"@": style,
|
||||||
|
"#": style,
|
||||||
|
},
|
||||||
builder: (context, key) => TextFormField(
|
builder: (context, key) => TextFormField(
|
||||||
enabled: canSendMessages,
|
enabled: canSendMessages,
|
||||||
maxLines: 12,
|
maxLines: 12,
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: canSendMessages
|
hintText: "Your message here...",
|
||||||
? "Your message here..."
|
|
||||||
: "You don't have permission to send messages in this room...",
|
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
),
|
),
|
||||||
controller: controller.value,
|
controller: controller.value,
|
||||||
|
|
@ -165,6 +168,14 @@ class ChatBox extends HookConsumerWidget {
|
||||||
icon: Icon(Icons.send),
|
icon: Icon(Icons.send),
|
||||||
tooltip: "Send message",
|
tooltip: "Send message",
|
||||||
),
|
),
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsetsGeometry.all(8),
|
||||||
|
child: Text(
|
||||||
|
"You don't have permission to send messages in this room...",
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,11 @@ class RoomChat extends HookConsumerWidget {
|
||||||
List<PopupMenuEntry> getMessageOptions(Message message) {
|
List<PopupMenuEntry> getMessageOptions(Message message) {
|
||||||
final isSentByMe = message.authorId == userId;
|
final isSentByMe = message.authorId == userId;
|
||||||
return [
|
return [
|
||||||
|
if (ref.watch(
|
||||||
|
PowerLevelController.provider(
|
||||||
|
PowerLevelConfig(eventType: "m.reaction"),
|
||||||
|
),
|
||||||
|
))
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -126,6 +131,11 @@ class RoomChat extends HookConsumerWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (ref.watch(
|
||||||
|
PowerLevelController.provider(
|
||||||
|
PowerLevelConfig(eventType: "m.room.message"),
|
||||||
|
),
|
||||||
|
))
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
relatedMessage.value = message;
|
relatedMessage.value = message;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue