feat(@desktop/chat): download messages

fixes #3508
This commit is contained in:
Anthony Laibe 2021-09-15 12:59:01 +02:00 committed by Iuri Matias
parent dc8294b6bd
commit 5ce06a94cc
8 changed files with 47 additions and 4 deletions

View File

@ -573,5 +573,4 @@ QtObject:
self.status.chat.createOneToOneChat(pubKey)
self.setActiveChannel(pubKey)
return
echo "Unsupported deep link structure: " & uri
echo "Unsupported deep link structure: " & uri

View File

@ -305,3 +305,4 @@ QtObject:
proc removeChat*(self: ChannelView, chatId: string) =
discard self.chats.removeChatItemFromList(chatId)
self.setActiveChannel(backToFirstChat)

View File

@ -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)

View File

@ -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 {

View File

@ -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

View File

@ -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

2
vendor/DOtherSide vendored

@ -1 +1 @@
Subproject commit 9da380cf964df3bcddbbd4ac929223a322523465
Subproject commit 10af6b307428612fa974d1ba3d70649351b766b0

2
vendor/nimqml vendored

@ -1 +1 @@
Subproject commit b67014a56a8d525f0fef7d4600d449138b16bdcb
Subproject commit ca381eb8a20cf02f712a423f85b22901e14fa982