2019-11-16 17:24:03 +00:00
|
|
|
import socket from "../socket";
|
2022-06-19 00:25:21 +00:00
|
|
|
import {store} from "../store";
|
2018-07-10 07:49:23 +00:00
|
|
|
|
2019-11-16 17:24:03 +00:00
|
|
|
function input() {
|
2022-06-19 00:25:21 +00:00
|
|
|
if (!store.state.activeChannel) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const messageIds: number[] = [];
|
2019-11-04 10:41:04 +00:00
|
|
|
|
|
|
|
for (const message of store.state.activeChannel.channel.messages) {
|
|
|
|
let toggled = false;
|
|
|
|
|
|
|
|
for (const preview of message.previews) {
|
|
|
|
if (!preview.shown) {
|
|
|
|
preview.shown = true;
|
|
|
|
toggled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (toggled) {
|
|
|
|
messageIds.push(message.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tell the server we're toggling so it remembers at page reload
|
2022-02-18 20:21:17 +00:00
|
|
|
if (!document.body.classList.contains("public") && messageIds.length > 0) {
|
2019-11-04 10:41:04 +00:00
|
|
|
socket.emit("msg:preview:toggle", {
|
2022-06-19 00:25:21 +00:00
|
|
|
target: store.state.activeChannel?.channel.id,
|
2019-11-04 10:41:04 +00:00
|
|
|
messageIds: messageIds,
|
|
|
|
shown: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-10 07:49:23 +00:00
|
|
|
return true;
|
2019-11-16 17:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {input};
|