Refix Event.source, JSONify dicts for ListModel

This commit is contained in:
miruka
2020-02-12 13:04:46 -04:00
parent ae780345e8
commit ce0a868579
9 changed files with 37 additions and 28 deletions

View File

@@ -64,8 +64,11 @@ HColumnLayout {
function json() {
const events = ModelStore.get(chat.userId, chat.roomId, "events")
return JSON.stringify(events.get(model.id), null, 4)
let event = ModelStore.get(chat.userId, chat.roomId, "events")
.get(model.id)
event = JSON.parse(JSON.stringify(event))
event.source = JSON.parse(event.source)
return JSON.stringify(event, null, 4)
}
function openContextMenu() {

View File

@@ -40,6 +40,8 @@ HTile {
property EventMediaLoader loader
readonly property bool cryptDict: loader.singleMediaInfo.media_crypt_dict
readonly property bool cryptDict:
JSON.parse(loader.singleMediaInfo.media_crypt_dict)
readonly property bool isEncrypted: ! utils.isEmptyObject(cryptDict)
}

View File

@@ -15,9 +15,11 @@ HMxcImage {
mxc: thumbnail ?
(loader.thumbnailMxc || loader.mediaUrl) :
(loader.mediaUrl || loader.thumbnailMxc)
cryptDict: thumbnail && loader.thumbnailMxc ?
loader.singleMediaInfo.thumbnail_crypt_dict :
loader.singleMediaInfo.media_crypt_dict
cryptDict: JSON.parse(
thumbnail && loader.thumbnailMxc ?
loader.singleMediaInfo.thumbnail_crypt_dict :
loader.singleMediaInfo.media_crypt_dict
)
property EventMediaLoader loader

View File

@@ -80,7 +80,10 @@ HLoader {
if (! downloadedPath) print("Downloading " + loader.mediaUrl + " ...")
const args = [loader.mediaUrl, loader.singleMediaInfo.media_crypt_dict]
const args = [
loader.mediaUrl,
JSON.parse(loader.singleMediaInfo.media_crypt_dict)
]
py.callCoro("media_cache.get_media", args, path => {
if (! downloadedPath) print("Done: " + path)