TempInfo Messageeventmodel
Further improvements to the handling of `mediaInfo` in `messageeventmodel`. `blurhash` and `thumbnailInfo` are now replaced with a single `tempInfo` object that contains a single temp source. The priority is thumbnail > `blurhash` > empty if none exist. Fixes network/neochat#235
This commit is contained in:
committed by
Tobias Fella
parent
20443ba59f
commit
b82d3ab5ad
@@ -1150,14 +1150,19 @@ QVariantMap MessageEventModel::getMediaInfoFromFileInfo(const EventContent::File
|
||||
mediaInfo["height"] = castInfo->imageSize.height();
|
||||
|
||||
if (!isThumbnail) {
|
||||
mediaInfo["thumbnailInfo"] = getMediaInfoFromFileInfo(castInfo->thumbnailInfo(), eventId, true);
|
||||
}
|
||||
|
||||
QString blurhash = castInfo->originalInfoJson["xyz.amorgan.blurhash"].toString();
|
||||
if (blurhash.isEmpty()) {
|
||||
mediaInfo["blurhash"] = QUrl();
|
||||
} else {
|
||||
mediaInfo["blurhash"] = QUrl("image://blurhash/" + blurhash);
|
||||
QVariantMap tempInfo;
|
||||
auto thumbnailInfo = getMediaInfoFromFileInfo(castInfo->thumbnailInfo(), eventId, true);
|
||||
if (thumbnailInfo["source"].toUrl().scheme() == "mxc") {
|
||||
tempInfo = thumbnailInfo;
|
||||
} else {
|
||||
QString blurhash = castInfo->originalInfoJson["xyz.amorgan.blurhash"].toString();
|
||||
if (blurhash.isEmpty()) {
|
||||
tempInfo["source"] = QUrl();
|
||||
} else {
|
||||
tempInfo["source"] = QUrl("image://blurhash/" + blurhash);
|
||||
}
|
||||
}
|
||||
mediaInfo["tempInfo"] = tempInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1168,7 +1173,19 @@ QVariantMap MessageEventModel::getMediaInfoFromFileInfo(const EventContent::File
|
||||
mediaInfo["duration"] = castInfo->duration;
|
||||
|
||||
if (!isThumbnail) {
|
||||
mediaInfo["thumbnailInfo"] = getMediaInfoFromFileInfo(castInfo->thumbnailInfo(), eventId, true);
|
||||
QVariantMap tempInfo;
|
||||
auto thumbnailInfo = getMediaInfoFromFileInfo(castInfo->thumbnailInfo(), eventId, true);
|
||||
if (thumbnailInfo["source"].toUrl().scheme() == "mxc") {
|
||||
tempInfo = thumbnailInfo;
|
||||
} else {
|
||||
QString blurhash = castInfo->originalInfoJson["xyz.amorgan.blurhash"].toString();
|
||||
if (blurhash.isEmpty()) {
|
||||
tempInfo["source"] = QUrl();
|
||||
} else {
|
||||
tempInfo["source"] = QUrl("image://blurhash/" + blurhash);
|
||||
}
|
||||
}
|
||||
mediaInfo["tempInfo"] = tempInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user