thelounge/client/js/socket-events/msg_preview.js
2019-02-12 12:48:42 +02:00

19 lines
466 B
JavaScript

"use strict";
const socket = require("../socket");
const {vueApp, findChannel} = require("../vue");
socket.on("msg:preview", function(data) {
const {channel} = findChannel(data.chan);
const message = channel.messages.find((m) => m.id === data.id);
if (!message) {
return;
}
const previewIndex = message.previews.findIndex((m) => m.link === data.preview.link);
if (previewIndex > -1) {
vueApp.$set(message.previews, previewIndex, data.preview);
}
});