From 782599f90588336aac79976d744d2a699e884056 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 29 Nov 2020 13:33:14 +0100 Subject: [PATCH] Simplify remorse popups, see #206 --- .../ChatInformationPageContent.qml | 17 +++++++--------- qml/pages/ChatPage.qml | 20 ++++++++----------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/qml/components/chatInformationPage/ChatInformationPageContent.qml b/qml/components/chatInformationPage/ChatInformationPageContent.qml index 9fbf08e..a1f29a6 100644 --- a/qml/components/chatInformationPage/ChatInformationPageContent.qml +++ b/qml/components/chatInformationPage/ChatInformationPageContent.qml @@ -204,18 +204,15 @@ SilicaFlickable { onClicked: { // ensure it's done even if the page is closed: if (chatInformationPage.userIsMember) { - var remorse = Remorse.popupAction(appWindow, qsTr("Leaving chat"), (function(chatid) { - return function() { - tdLibWrapper.leaveChat(chatid); - // this does not care about the response (ideally type "ok" without further reference) for now - pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} )); - }; - }(chatInformationPage.chatInformation.id))) + var chatId = chatInformationPage.chatInformation.id; + Remorse.popupAction(chatInformationPage, qsTr("Leaving chat"), function() { + tdLibWrapper.leaveChat(chatId); + // this does not care about the response (ideally type "ok" without further reference) for now + pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} )); + }); } else { tdLibWrapper.joinChat(chatInformationPage.chatInformation.id); } - - } } MenuItem { @@ -251,7 +248,7 @@ SilicaFlickable { property int maxDimension: Screen.width / 2 property int minX: Theme.horizontalPageMargin property int maxX: (chatInformationPage.width - maxDimension)/2 - property int minY: Theme.paddingSmall//(parent.height - minDimension)/2 + property int minY: Theme.paddingMedium property int maxY: parent.height property double tweenFactor: { if(!hasImage) { diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index bffe528..b078755 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -587,11 +587,8 @@ Page { id: closeSecretChatMenuItem visible: chatPage.isSecretChat && chatPage.secretChatDetails.state["@type"] !== "secretChatStateClosed" onClicked: { - var remorse = Remorse.popupAction(appWindow, qsTr("Closing chat"), (function(secretChatId) { - return function() { - tdLibWrapper.closeSecretChat(secretChatId); - }; - }(chatPage.secretChatDetails.id))) + var secretChatId = chatPage.secretChatDetails.id; + Remorse.popupAction(chatPage, qsTr("Closing chat"), function() { tdLibWrapper.closeSecretChat(secretChatId) }); } text: qsTr("Close Chat") } @@ -601,13 +598,12 @@ Page { visible: (chatPage.isSuperGroup || chatPage.isBasicGroup) && chatGroupInformation && chatGroupInformation.status["@type"] !== "chatMemberStatusBanned" onClicked: { if (chatPage.userIsMember) { - var remorse = Remorse.popupAction(appWindow, qsTr("Leaving chat"), (function(chatid) { - return function() { - tdLibWrapper.leaveChat(chatid); - // this does not care about the response (ideally type "ok" without further reference) for now - pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} )); - }; - }(chatInformation.id))) + var chatId = chatInformation.id; + Remorse.popupAction(chatPage, qsTr("Leaving chat"), function() { + tdLibWrapper.leaveChat(chatId); + // this does not care about the response (ideally type "ok" without further reference) for now + pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} )); + }); } else { tdLibWrapper.joinChat(chatInformation.id); }