Add 'Forward Message' to options drawer, fix SFOS 4.0.1 bug

This commit is contained in:
Sebastian Wolf 2021-02-17 23:48:08 +01:00
parent 8ae148ec90
commit 1a409407c9
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
14 changed files with 78 additions and 10 deletions

View file

@ -335,6 +335,18 @@ Page {
}
function startForwardingMessages(messages) {
var ids = Functions.getMessagesArrayIds(messages);
var neededPermissions = Functions.getMessagesNeededForwardPermissions(messages);
var chatId = chatInformation.id;
pageStack.push(Qt.resolvedUrl("../pages/ChatSelectionPage.qml"), {
myUserId: chatPage.myUserId,
headerDescription: qsTr("Forward %Ln messages", "dialog header", ids.length),
payload: {fromChatId: chatId, messageIds:ids, neededPermissions: neededPermissions},
state: "forwardMessages"
});
}
function forwardMessages(fromChatId, messageIds) {
forwardMessagesTimer.fromChatId = fromChatId;
forwardMessagesTimer.messageIds = messageIds;
@ -697,6 +709,14 @@ Page {
name: qsTr("Copy Message to Clipboard")
action: function () { Clipboard.text = Functions.getMessageText(messageOptionsDrawer.myMessage, true, messageOptionsDrawer.userInformation.id, true); }
},
NamedAction {
visible: messageOptionsDrawer.myMessage.can_be_forwarded
name: qsTr("Forward Message")
action: function () {
var messagesToForward = [ messageOptionsDrawer.myMessage ];
startForwardingMessages(messagesToForward);
}
},
NamedAction {
visible: canPinMessages()
name: messageOptionsDrawer.myMessage.is_pinned ? qsTr("Unpin Message") : qsTr("Pin Message")
@ -2029,15 +2049,7 @@ Page {
icon.sourceSize: Qt.size(Theme.iconSizeMedium, Theme.iconSizeMedium)
icon.source: "image://theme/icon-m-forward"
onClicked: {
var ids = Functions.getMessagesArrayIds(chatPage.selectedMessages)
var neededPermissions = Functions.getMessagesNeededForwardPermissions(chatPage.selectedMessages)
var chatId = chatInformation.id
pageStack.push(Qt.resolvedUrl("../pages/ChatSelectionPage.qml"), {
myUserId: chatPage.myUserId,
headerDescription: qsTr("Forward %Ln messages", "dialog header", ids.length),
payload: {fromChatId: chatId, messageIds:ids, neededPermissions: neededPermissions},
state: "forwardMessages"
})
startForwardingMessages(chatPage.selectedMessages);
}
}

View file

@ -28,10 +28,18 @@ Dialog {
allowedOrientations: Orientation.All
canAccept: false
acceptDestinationAction: PageStackAction.Replace
acceptDestinationReplaceTarget: pageStack.find( function(page){ return(page._depth === 0)} )
acceptDestinationReplaceTarget: pageStack.find( function(page){
// This crazy workaround is presented to you by a bug introduced with SFOS 4.0.1
// See https://forum.sailfishos.org/t/4-0-1-45-pagestack-find-not-working-properly-anymore-in-a-dialog/4723 for details.
chatSelectionPage.currentDepth = chatSelectionPage.currentDepth - 1;
return(chatSelectionPage.currentDepth === 0);
} )
property int myUserId: tdLibWrapper.getUserInformation().id
property alias headerTitle: pageHeader.title
property alias headerDescription: pageHeader.description
property var currentDepth: pageStack.depth
/*
payload dependent on chatSelectionPage.state
- forwardMessages: {fromChatId, messageIds, neededPermissions}

View file

@ -463,6 +463,10 @@
<source>Delete Message</source>
<translation>Nachricht löschen</translation>
</message>
<message>
<source>Forward Message</source>
<translation>Nachricht weiterleiten</translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -463,6 +463,10 @@
<source>Delete Message</source>
<translation>Delete Message</translation>
</message>
<message>
<source>Forward Message</source>
<translation>Forward Message</translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -463,6 +463,10 @@
<source>Delete Message</source>
<translation>Borrar</translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -463,6 +463,10 @@
<source>Delete Message</source>
<translation>Poista viesti</translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -453,6 +453,10 @@
<source>Delete Message</source>
<translation type="unfinished">Üzenet törlése</translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -463,6 +463,10 @@
<source>Delete Message</source>
<translation>Cancella messaggio</translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -473,6 +473,10 @@
<source>Delete Message</source>
<translation>Usuń wiadomość</translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -473,6 +473,10 @@
<source>Delete Message</source>
<translation type="unfinished">Удалить</translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -473,6 +473,10 @@
<source>Delete Message</source>
<translation>Odstrániť správu</translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -463,6 +463,10 @@
<source>Delete Message</source>
<translation>Ta bort meddelandet</translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -453,6 +453,10 @@
<source>Delete Message</source>
<translation></translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>

View file

@ -463,6 +463,10 @@
<source>Delete Message</source>
<translation type="unfinished">Delete Message</translation>
</message>
<message>
<source>Forward Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatSelectionPage</name>