diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index ea905e9ffc..4695242ac8 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -573,5 +573,4 @@ QtObject: self.status.chat.createOneToOneChat(pubKey) self.setActiveChannel(pubKey) return - echo "Unsupported deep link structure: " & uri - \ No newline at end of file + echo "Unsupported deep link structure: " & uri \ No newline at end of file diff --git a/src/app/chat/views/channel.nim b/src/app/chat/views/channel.nim index b804e3c0de..2d9bedd20b 100644 --- a/src/app/chat/views/channel.nim +++ b/src/app/chat/views/channel.nim @@ -305,3 +305,4 @@ QtObject: proc removeChat*(self: ChannelView, chatId: string) = discard self.chats.removeChatItemFromList(chatId) self.setActiveChannel(backToFirstChat) + diff --git a/src/app/chat/views/messages.nim b/src/app/chat/views/messages.nim index 1aab9c2399..db2ce3d013 100644 --- a/src/app/chat/views/messages.nim +++ b/src/app/chat/views/messages.nim @@ -478,3 +478,16 @@ QtObject: self.searchedMessageLoaded(messageId) else: self.loadMessagesUntillMessageWithIdIsLoaded(messageId) + + proc downloadMessages*(self: MessageView, filePath: string) {.slot.} = + let messages = newJArray() + for message in self.messageList[self.channelView.activeChannel.id].messages: + if message.id == "": + continue + + messages.elems.add(%*{ + "id": message.id, "text": message.text, "clock": message.clock, + "alias": message.alias, "from": message.fromAuthor + }) + + writeFile(url_toLocalFile(filePath), $messages) \ No newline at end of file diff --git a/ui/app/AppLayouts/Chat/components/ChatContextMenu.qml b/ui/app/AppLayouts/Chat/components/ChatContextMenu.qml index 743c3add06..8834762f0e 100644 --- a/ui/app/AppLayouts/Chat/components/ChatContextMenu.qml +++ b/ui/app/AppLayouts/Chat/components/ChatContextMenu.qml @@ -1,6 +1,7 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.13 +import Qt.labs.platform 1.1 import "./" import "../../../../shared" import "../../../../imports" @@ -106,6 +107,13 @@ StatusPopupMenu { }) } + StatusMenuItem { + text: qsTr("Download") + enabled: appSettings.downloadChannelMessagesEnabled + icon.name: "download" + onTriggered: downdloadDialog.open() + } + StatusMenuSeparator { visible: deleteOrLeaveMenuItem.enabled } @@ -143,6 +151,18 @@ StatusPopupMenu { enabled: !communityActive || chatsModel.communities.activeCommunity.admin } + FileDialog { + id: downdloadDialog + acceptLabel: qsTr("Save") + fileMode: FileDialog.SaveFile + title: qsTr("Download messages") + currentFile: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) + "/messages.json" + defaultSuffix: "json" + onAccepted: { + chatsModel.messageView.downloadMessages(downdloadDialog.currentFile) + } + } + Component { id: deleteChatConfirmationDialogComponent ConfirmationDialog { diff --git a/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml b/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml index e3793f2ebc..94ec31a015 100644 --- a/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml @@ -264,6 +264,15 @@ ScrollView { } } + StatusSettingsLineButton { + text: qsTr("Download messages") + isSwitch: true + switchChecked: appSettings.downloadChannelMessagesEnabled + onClicked: { + appSettings.downloadChannelMessagesEnabled = !appSettings.downloadChannelMessagesEnabled + } + } + StatusSettingsLineButton { text: qsTr("Stickers/ENS on ropsten") visible: profileModel.network.current === Constants.networkRopsten diff --git a/ui/app/AppMain.qml b/ui/app/AppMain.qml index 0b3d8e35c9..db4246bf9d 100644 --- a/ui/app/AppMain.qml +++ b/ui/app/AppMain.qml @@ -186,6 +186,7 @@ Item { property bool quitOnClose: false property string skinColor: "" property bool showDeleteMessageWarning: true + property bool downloadChannelMessagesEnabled: false // Browser settings property bool showBrowserSelector: true diff --git a/vendor/DOtherSide b/vendor/DOtherSide index 9da380cf96..10af6b3074 160000 --- a/vendor/DOtherSide +++ b/vendor/DOtherSide @@ -1 +1 @@ -Subproject commit 9da380cf964df3bcddbbd4ac929223a322523465 +Subproject commit 10af6b307428612fa974d1ba3d70649351b766b0 diff --git a/vendor/nimqml b/vendor/nimqml index b67014a56a..ca381eb8a2 160000 --- a/vendor/nimqml +++ b/vendor/nimqml @@ -1 +1 @@ -Subproject commit b67014a56a8d525f0fef7d4600d449138b16bdcb +Subproject commit ca381eb8a20cf02f712a423f85b22901e14fa982