diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 18690ce..c4c96e2 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -267,14 +267,15 @@ Page { forwardMessagesTimer.start(); } function hasSendPrivilege(privilege) { - return chatPage.isPrivateChat || - chatGroupInformation && - ( - (chatGroupInformation.status["@type"] === "chatMemberStatusMember" && chatGroupInformation.status.permissions[privilege]) - || chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator" - || chatGroupInformation.status["@type"] === "chatMemberStatusCreator" - || (chatGroupInformation.status["@type"] === "chatMemberStatusRestricted" && chatGroupInformation.status.permissions[privilege]) - ) + var groupStatus = chatGroupInformation ? chatGroupInformation.status : null; + var groupStatusType = grouptStatus ? groupStatus["@type"] : null; + return chatPage.isPrivateChat + || (groupStatusType === "chatMemberStatusMember" && chatInformation.permissions[privilege]) + || groupStatusType === "chatMemberStatusAdministrator" + || groupStatusType === "chatMemberStatusCreator" + || (groupStatusType === "chatMemberStatusRestricted" && groupStatus.permissions[privilege]) + + } Timer { diff --git a/qml/pages/ChatSelectionPage.qml b/qml/pages/ChatSelectionPage.qml index e975331..b6924e8 100644 --- a/qml/pages/ChatSelectionPage.qml +++ b/qml/pages/ChatSelectionPage.qml @@ -73,11 +73,11 @@ Dialog { asynchronous: true sourceComponent: Component { QtObject { - property var chatGroupInformation: ({}) property bool visible: false Component.onCompleted: { if(chatSelectionPage.state === "forwardMessages") { var chatType = display.type['@type']; + var chatGroupInformation; if(chatType === "chatTypePrivate" || chatType === "chatTypeSecret") { visible = true return; @@ -88,14 +88,22 @@ Dialog { else if (chatType === "chatTypeSupergroup" ) { chatGroupInformation = tdLibWrapper.getSuperGroup(display.type.supergroup_id); } - - visible = (chatGroupInformation.status["@type"] === "chatMemberStatusCreator" - || chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator" - || (chatGroupInformation.status["@type"] === "chatMemberStatusMember" + var groupStatus = chatGroupInformation.status; + var groupStatusType = groupStatus["@type"]; + var groupStatusPermissions = groupStatus.permissions; + var groupPermissions = display.permissions; + visible = (groupStatusType === "chatMemberStatusCreator" + || groupStatusType === "chatMemberStatusAdministrator" + || (groupStatusType === "chatMemberStatusMember" && chatSelectionPage.payload.neededPermissions.every(function(neededPermission){ - return display.permissions[neededPermission]; + return groupPermissions[neededPermission]; }) ) + || (groupStatusType === "chatMemberStatusRestricted" + && chatSelectionPage.payload.neededPermissions.every(function(neededPermission){ + return groupStatusPermissions[neededPermission]; + }) + ) ); } else { // future uses of chat selection can be processed here visible = true;