2017-06-26 09:01:55 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-11-11 21:39:09 +00:00
|
|
|
import Vue from "vue";
|
|
|
|
|
2017-06-26 09:01:55 +00:00
|
|
|
const socket = require("../socket");
|
2019-11-03 14:59:43 +00:00
|
|
|
const store = require("../store").default;
|
2017-06-26 09:01:55 +00:00
|
|
|
|
|
|
|
socket.on("msg:preview", function(data) {
|
2019-11-03 14:59:43 +00:00
|
|
|
const {channel} = store.getters.findChannel(data.chan);
|
2018-07-10 11:57:11 +00:00
|
|
|
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) {
|
2019-11-11 21:39:09 +00:00
|
|
|
Vue.set(message.previews, previewIndex, data.preview);
|
2018-07-10 11:57:11 +00:00
|
|
|
}
|
2017-06-26 09:01:55 +00:00
|
|
|
});
|