thelounge/client/js/socket-events/msg_preview.js
2021-12-01 15:15:59 -08:00

21 lines
472 B
JavaScript

"use strict";
import socket from "../socket";
import store from "../store";
socket.on("msg:preview", function (data) {
const {channel} = store.getters.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) {
// TODO: Does this work?
message.previews[previewIndex] = data.preview;
}
});