mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-07-15 21:15:24 +02:00
chat-view: fix loading data transfer items
- Avoids manually building local file URIs which was causing long load times for conversations on Windows. - Fixes an issue where missing images were caused by a interaction updates erasing the message bodies. Change-Id: I4c65f73cf9f46da5a9ae899940cb205cb34ffae2
This commit is contained in:
parent
7060afe467
commit
3d3b4612df
9 changed files with 34 additions and 28 deletions
|
@ -40,19 +40,20 @@ Loader {
|
|||
property int seq: MsgSeq.single
|
||||
property string author: Author
|
||||
property string body: Body
|
||||
property var transferStatus: Status
|
||||
property int transferStatus: Status
|
||||
onTransferStatusChanged: {
|
||||
if (transferStatus === Interaction.Status.TRANSFER_FINISHED) {
|
||||
mediaInfo = MessagesAdapter.getMediaInfo(root.body);
|
||||
if (Object.keys(mediaInfo).length !== 0 && WITH_WEBENGINE) {
|
||||
sourceComponent = localMediaMsgComp;
|
||||
return;
|
||||
}
|
||||
}
|
||||
sourceComponent = dataTransferMsgComp;
|
||||
}
|
||||
|
||||
width: ListView.view ? ListView.view.width : 0
|
||||
|
||||
sourceComponent: {
|
||||
if (root.transferStatus === Interaction.Status.TRANSFER_FINISHED) {
|
||||
mediaInfo = MessagesAdapter.getMediaInfo(root.body)
|
||||
if (Object.keys(mediaInfo).length !== 0 && WITH_WEBENGINE)
|
||||
return localMediaMsgComp
|
||||
}
|
||||
return dataTransferMsgComp
|
||||
}
|
||||
|
||||
opacity: 0
|
||||
Behavior on opacity { NumberAnimation { duration: 100 } }
|
||||
onLoaded: opacity = 1
|
||||
|
@ -294,8 +295,6 @@ Loader {
|
|||
return avComp
|
||||
}
|
||||
|
||||
|
||||
|
||||
Component {
|
||||
id: avComp
|
||||
|
||||
|
@ -304,7 +303,7 @@ Loader {
|
|||
var qml = WITH_WEBENGINE ?
|
||||
"qrc:/webengine/MediaPreviewBase.qml" :
|
||||
"qrc:/nowebengine/MediaPreviewBase.qml"
|
||||
setSource( qml, { isVideo: mediaInfo.isVideo, html:mediaInfo.html } )
|
||||
setSource( qml, { isVideo: mediaInfo.isVideo, html: mediaInfo.html } )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -383,9 +382,11 @@ Loader {
|
|||
antialiasing: true
|
||||
autoTransform: true
|
||||
asynchronous: true
|
||||
source: Body !== undefined ? UtilsAdapter.urlFromLocalPath(Body) : ''
|
||||
|
||||
Component.onCompleted: localMediaMsgItem.bubble.imgSource = source
|
||||
Component.onCompleted: {
|
||||
source = UtilsAdapter.urlFromLocalPath(Body);
|
||||
localMediaMsgItem.bubble.imgSource = source;
|
||||
}
|
||||
|
||||
// The sourceSize represents the maximum source dimensions.
|
||||
// This should not be a dynamic binding, as property changes
|
||||
|
@ -401,7 +402,6 @@ Loader {
|
|||
if (img.status == Image.Ready && aspectRatio) {
|
||||
height = Qt.binding(() => JamiQmlUtils.clamp(idealWidth / aspectRatio, 64, 256))
|
||||
width = Qt.binding(() => height * aspectRatio)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ messageHandler(QtMsgType type, const QMessageLogContext& context, const QString&
|
|||
// In debug mode, always include file URI (including line info).
|
||||
// Only do this when the level Info/Debug, as it is already included in the constructed
|
||||
// message for the other levels.
|
||||
if (type == QtDebugMsg || type == QtInfoMsg) {
|
||||
if (type == QtDebugMsg || type == QtInfoMsg || !isQml) {
|
||||
auto fileName = isQml ? context.file : QUrl::fromLocalFile(context.file).toString();
|
||||
fileLineInfo = QString(" %1:%2").arg(!fileName.isEmpty() ? fileName : "unknown",
|
||||
context.line ? QString::number(context.line) : "0");
|
||||
|
|
|
@ -128,11 +128,11 @@ Item {
|
|||
fillMode: Image.PreserveAspectCrop
|
||||
|
||||
source: {
|
||||
fileSource = "file://" + Body;
|
||||
fileSource = UtilsAdapter.urlFromLocalPath(Body);
|
||||
if (!mediaInfo.isImage && !mediaInfo.isAnimatedImage) {
|
||||
return "";
|
||||
}
|
||||
return "file://" + Body;
|
||||
return fileSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ JamiListView {
|
|||
id: overlay
|
||||
anchors.fill: parent
|
||||
color: JamiTheme.chatviewBgColor
|
||||
visible: opacity !== 0
|
||||
visible: opacity > 0
|
||||
SequentialAnimation {
|
||||
id: fadeAnimation
|
||||
NumberAnimation {
|
||||
|
|
|
@ -41,7 +41,7 @@ WebEngineView {
|
|||
}
|
||||
settings.fullScreenSupportEnabled: isVideo
|
||||
settings.javascriptCanOpenWindows: false
|
||||
Component.onCompleted: loadHtml(html, 'file://')
|
||||
Component.onCompleted: loadHtml(html, 'file:///')
|
||||
layer.enabled: !isFullScreen
|
||||
layer.effect: OpacityMask {
|
||||
maskSource: MessageBubble {
|
||||
|
|
|
@ -35,7 +35,7 @@ Rectangle {
|
|||
anchors.topMargin: root.isVideo ? 0 : wev.implicitHeight / 2
|
||||
settings.fullScreenSupportEnabled: root.isVideo
|
||||
settings.javascriptCanOpenWindows: false
|
||||
Component.onCompleted: loadHtml(root.html, 'file://')
|
||||
Component.onCompleted: loadHtml(root.html, 'file:///')
|
||||
onFullScreenRequested: function (request) {
|
||||
if (request.toggleOn) {
|
||||
layoutManager.pushFullScreenItem(this, root, null, function () {
|
||||
|
|
|
@ -443,8 +443,10 @@ struct Info
|
|||
Info(const SwarmMessage& msg, const QString& accountUri)
|
||||
{
|
||||
MapStringString msgBody;
|
||||
for (const auto& key : msg.body.keys()) {
|
||||
msgBody.insert(key, msg.body.value(key));
|
||||
for (auto it = msg.body.cbegin(); it != msg.body.cend(); ++it) {
|
||||
const auto& key = it.key();
|
||||
const auto& value = it.value();
|
||||
msgBody.insert(key, value);
|
||||
}
|
||||
init(msgBody, accountUri);
|
||||
parentId = msg.linearizedParent;
|
||||
|
|
|
@ -2381,7 +2381,8 @@ ConversationModelPimpl::slotMessageReceived(const QString& accountId,
|
|||
auto msg = interaction::Info(message, linked.owner.profileInfo.uri);
|
||||
|
||||
if (msg.type == interaction::Type::CALL) {
|
||||
msg.body = interaction::getCallInteractionString(msg.authorUri == linked.owner.profileInfo.uri,
|
||||
msg.body = interaction::getCallInteractionString(msg.authorUri
|
||||
== linked.owner.profileInfo.uri,
|
||||
msg);
|
||||
} else if (msg.type == interaction::Type::DATA_TRANSFER) {
|
||||
// save data transfer interaction to db and assosiate daemon id with interaction id,
|
||||
|
@ -2851,7 +2852,7 @@ ConversationModelPimpl::addConversationRequest(const MapStringString& convReques
|
|||
void
|
||||
ConversationModelPimpl::slotPendingContactAccepted(const QString& uri)
|
||||
{
|
||||
profile::Type type;
|
||||
profile::Type type {};
|
||||
try {
|
||||
type = linked.owner.contactModel->getContact(uri).profileInfo.type;
|
||||
} catch (std::out_of_range& e) {
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "api/accountmodel.h"
|
||||
#include "api/contactmodel.h"
|
||||
#include "api/conversationmodel.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
|
@ -186,7 +185,11 @@ MessageListModel::update(const QString& id, const interaction::Info& interaction
|
|||
return true;
|
||||
}
|
||||
}
|
||||
// Just update bodies notify the view.
|
||||
// DataTransfer interactions should not be updated.
|
||||
if (current.type == interaction::Type::DATA_TRANSFER) {
|
||||
return true;
|
||||
}
|
||||
// Just update bodies notify the view otherwise.
|
||||
current.body = interaction.body;
|
||||
current.previousBodies = interaction.previousBodies;
|
||||
current.parsedBody = interaction.parsedBody;
|
||||
|
|
Loading…
Add table
Reference in a new issue