2018-07-10 07:49:23 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-11-04 10:41:04 +00:00
|
|
|
const socket = require("../socket");
|
|
|
|
const store = require("../store").default;
|
2018-07-10 07:49:23 +00:00
|
|
|
|
|
|
|
exports.input = function() {
|
2019-11-04 10:41:04 +00:00
|
|
|
const messageIds = [];
|
|
|
|
|
|
|
|
for (const message of store.state.activeChannel.channel.messages) {
|
|
|
|
let toggled = false;
|
|
|
|
|
|
|
|
for (const preview of message.previews) {
|
|
|
|
if (preview.shown) {
|
|
|
|
preview.shown = false;
|
|
|
|
toggled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (toggled) {
|
|
|
|
messageIds.push(message.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tell the server we're toggling so it remembers at page reload
|
|
|
|
if (messageIds.length > 0) {
|
|
|
|
socket.emit("msg:preview:toggle", {
|
|
|
|
target: store.state.activeChannel.channel.id,
|
|
|
|
messageIds: messageIds,
|
|
|
|
shown: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-10 07:49:23 +00:00
|
|
|
return true;
|
|
|
|
};
|