fix(chat input): should be disabled if user is not able to post
- extend `isUserAllowedToSendMessage` to also cover `Constants.chatType.communityChat` - let `admin` always satisfy the permissions - hide the add emoji/reaction button instead of disabling it when the permissions are not met - adjust the error msg to better reflect the reality (tokens vs. permissions) Fixes #13777
This commit is contained in:
parent
954b25a54c
commit
b623c8fb2b
|
@ -168,7 +168,7 @@ QtObject:
|
||||||
self.viewOnlyPermissionsSatisfiedChanged()
|
self.viewOnlyPermissionsSatisfiedChanged()
|
||||||
|
|
||||||
proc getViewOnlyPermissionsSatisfied*(self: View): bool {.slot.} =
|
proc getViewOnlyPermissionsSatisfied*(self: View): bool {.slot.} =
|
||||||
return self.viewOnlyPermissionsSatisfied
|
return self.viewOnlyPermissionsSatisfied or self.amIChatAdmin()
|
||||||
QtProperty[bool] viewOnlyPermissionsSatisfied:
|
QtProperty[bool] viewOnlyPermissionsSatisfied:
|
||||||
read = getViewOnlyPermissionsSatisfied
|
read = getViewOnlyPermissionsSatisfied
|
||||||
notify = viewOnlyPermissionsSatisfiedChanged
|
notify = viewOnlyPermissionsSatisfiedChanged
|
||||||
|
@ -180,7 +180,7 @@ QtObject:
|
||||||
self.viewAndPostPermissionsSatisfiedChanged()
|
self.viewAndPostPermissionsSatisfiedChanged()
|
||||||
|
|
||||||
proc getViewAndPostPermissionsSatisfied*(self: View): bool {.slot.} =
|
proc getViewAndPostPermissionsSatisfied*(self: View): bool {.slot.} =
|
||||||
return self.viewAndPostPermissionsSatisfied
|
return self.viewAndPostPermissionsSatisfied or self.amIChatAdmin()
|
||||||
QtProperty[bool] viewAndPostPermissionsSatisfied:
|
QtProperty[bool] viewAndPostPermissionsSatisfied:
|
||||||
read = getViewAndPostPermissionsSatisfied
|
read = getViewAndPostPermissionsSatisfied
|
||||||
notify = viewAndPostPermissionsSatisfiedChanged
|
notify = viewAndPostPermissionsSatisfiedChanged
|
||||||
|
|
|
@ -155,6 +155,7 @@ Item {
|
||||||
Item {
|
Item {
|
||||||
width: addEmojiButton.width + addEmojiButton.anchors.leftMargin // there is more margin between the button and the emojis than between each emoji
|
width: addEmojiButton.width + addEmojiButton.anchors.leftMargin // there is more margin between the button and the emojis than between each emoji
|
||||||
height: addEmojiButton.height
|
height: addEmojiButton.height
|
||||||
|
visible: root.enabled
|
||||||
|
|
||||||
StatusIcon {
|
StatusIcon {
|
||||||
id: addEmojiButton
|
id: addEmojiButton
|
||||||
|
|
|
@ -589,6 +589,7 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property QtObject _d: QtObject {
|
readonly property QtObject _d: QtObject {
|
||||||
|
id: _d
|
||||||
readonly property var sectionDetailsInstantiator: Instantiator {
|
readonly property var sectionDetailsInstantiator: Instantiator {
|
||||||
model: SortFilterProxyModel {
|
model: SortFilterProxyModel {
|
||||||
sourceModel: mainModuleInst.sectionsModel
|
sourceModel: mainModuleInst.sectionsModel
|
||||||
|
@ -655,9 +656,10 @@ QtObject {
|
||||||
readonly property bool isUserAllowedToSendMessage: {
|
readonly property bool isUserAllowedToSendMessage: {
|
||||||
if (_d.activeChatType === Constants.chatType.oneToOne && _d.oneToOneChatContact) {
|
if (_d.activeChatType === Constants.chatType.oneToOne && _d.oneToOneChatContact) {
|
||||||
return _d.oneToOneChatContact.contactRequestState === Constants.ContactRequestState.Mutual
|
return _d.oneToOneChatContact.contactRequestState === Constants.ContactRequestState.Mutual
|
||||||
}
|
} else if (_d.activeChatType === Constants.chatType.privateGroupChat) {
|
||||||
else if(_d.activeChatType === Constants.chatType.privateGroupChat) {
|
|
||||||
return _d.amIMember
|
return _d.amIMember
|
||||||
|
} else if (_d.activeChatType === Constants.chatType.communityChat) {
|
||||||
|
return currentChatContentModule().viewAndPostPermissionsSatisfied
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -278,7 +278,7 @@ Item {
|
||||||
return qsTr("You need to join this community to send messages")
|
return qsTr("You need to join this community to send messages")
|
||||||
}
|
}
|
||||||
if (!root.viewAndPostPermissionsSatisfied) {
|
if (!root.viewAndPostPermissionsSatisfied) {
|
||||||
return qsTr("Sorry, you don't have the tokens needed to post in this channel.")
|
return qsTr("Sorry, you don't have permissions to post in this channel.")
|
||||||
}
|
}
|
||||||
return root.rootStore.chatInputPlaceHolderText
|
return root.rootStore.chatInputPlaceHolderText
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -205,7 +205,7 @@ StatusSectionLayout {
|
||||||
emojiPopup: root.emojiPopup
|
emojiPopup: root.emojiPopup
|
||||||
stickersPopup: root.stickersPopup
|
stickersPopup: root.stickersPopup
|
||||||
viewAndPostHoldingsModel: root.viewAndPostPermissionsModel
|
viewAndPostHoldingsModel: root.viewAndPostPermissionsModel
|
||||||
viewAndPostPermissionsSatisfied: !root.rootStore.chatCommunitySectionModule.isCommunity() || root.amISectionAdmin || root.viewAndPostPermissionsSatisfied
|
viewAndPostPermissionsSatisfied: !root.rootStore.chatCommunitySectionModule.isCommunity() || root.viewAndPostPermissionsSatisfied
|
||||||
amISectionAdmin: root.amISectionAdmin
|
amISectionAdmin: root.amISectionAdmin
|
||||||
onOpenStickerPackPopup: {
|
onOpenStickerPackPopup: {
|
||||||
Global.openPopup(statusStickerPackClickPopup, {packId: stickerPackId, store: root.stickersPopup.store} )
|
Global.openPopup(statusStickerPackClickPopup, {packId: stickerPackId, store: root.stickersPopup.store} )
|
||||||
|
|
|
@ -1226,7 +1226,7 @@ Rectangle {
|
||||||
|
|
||||||
objectName: "messageInputField"
|
objectName: "messageInputField"
|
||||||
|
|
||||||
property var lastClick: 0
|
property double lastClick: 0
|
||||||
property int cursorWhenPressed: 0
|
property int cursorWhenPressed: 0
|
||||||
property int previousCursorPosition: 0
|
property int previousCursorPosition: 0
|
||||||
|
|
||||||
|
@ -1246,7 +1246,7 @@ Rectangle {
|
||||||
padding: 0
|
padding: 0
|
||||||
// This is needed to make sure the text area is disabled when the input is disabled
|
// This is needed to make sure the text area is disabled when the input is disabled
|
||||||
Binding on enabled {
|
Binding on enabled {
|
||||||
value: root.enabled
|
value: control.enabled
|
||||||
}
|
}
|
||||||
Keys.onUpPressed: {
|
Keys.onUpPressed: {
|
||||||
if (isEdit && !activeFocus) {
|
if (isEdit && !activeFocus) {
|
||||||
|
|
|
@ -651,7 +651,7 @@ Loader {
|
||||||
(root.chatLogView && root.chatLogView.moving) ||
|
(root.chatLogView && root.chatLogView.moving) ||
|
||||||
Global.activityPopupOpened
|
Global.activityPopupOpened
|
||||||
|
|
||||||
disableEmojis: root.isChatBlocked
|
disableEmojis: !d.addReactionAllowed
|
||||||
hideMessage: d.hideMessage
|
hideMessage: d.hideMessage
|
||||||
|
|
||||||
overrideBackground: root.placeholderMessage
|
overrideBackground: root.placeholderMessage
|
||||||
|
|
Loading…
Reference in New Issue