Display previews as they come in; fix image viewer

This commit is contained in:
Pavel Djundik 2018-07-11 14:33:06 +03:00 committed by Pavel Djundik
parent c6262a36e6
commit 5792bff49d
3 changed files with 8 additions and 4 deletions

View File

@ -124,10 +124,8 @@ export default {
link: Object,
},
mounted() {
if (this.link.shown) {
const options = require("../js/options");
this.$set(this.link, "canDisplay", options.shouldOpenMessagePreview(this.link.type));
}
const options = require("../js/options");
this.$set(this.link, "canDisplay", this.link.type !== "loading" && options.shouldOpenMessagePreview(this.link.type));
},
methods: {
onPreviewReady() {

View File

@ -60,6 +60,9 @@ export default {
return "message-" + this.message.type;
},
},
mounted() {
require("../js/renderPreview");
},
methods: {
isAction() {
return typeof MessageTypes["message-" + this.message.type] !== "undefined";

View File

@ -1,6 +1,7 @@
"use strict";
const socket = require("../socket");
const {shouldOpenMessagePreview} = require("../options");
const {vueApp, findChannel} = require("../vue");
socket.on("msg:preview", function(data) {
@ -14,6 +15,8 @@ socket.on("msg:preview", function(data) {
const previewIndex = message.previews.findIndex((m) => m.link === data.preview.link);
if (previewIndex > -1) {
data.preview.canDisplay = shouldOpenMessagePreview(data.preview.type);
vueApp.$set(message.previews, previewIndex, data.preview);
}
});