From 5792bff49d33e6c13c4ee67a99cbe9114125a350 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 11 Jul 2018 14:33:06 +0300 Subject: [PATCH] Display previews as they come in; fix image viewer --- client/components/LinkPreview.vue | 6 ++---- client/components/Message.vue | 3 +++ client/js/socket-events/msg_preview.js | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/components/LinkPreview.vue b/client/components/LinkPreview.vue index 6d31f7f8..f5adfb79 100644 --- a/client/components/LinkPreview.vue +++ b/client/components/LinkPreview.vue @@ -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() { diff --git a/client/components/Message.vue b/client/components/Message.vue index 511037e3..207e04ed 100644 --- a/client/components/Message.vue +++ b/client/components/Message.vue @@ -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"; diff --git a/client/js/socket-events/msg_preview.js b/client/js/socket-events/msg_preview.js index 8a7ed712..55d0dd53 100644 --- a/client/js/socket-events/msg_preview.js +++ b/client/js/socket-events/msg_preview.js @@ -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); } });