mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 04:23:13 +00:00
dd05ee3a65
Co-authored-by: Eric Nemchik <eric@nemchik.com> Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
38 lines
768 B
TypeScript
38 lines
768 B
TypeScript
import socket from "../socket";
|
|
import {store} from "../store";
|
|
|
|
function input() {
|
|
if (!store.state.activeChannel) {
|
|
return;
|
|
}
|
|
|
|
const messageIds: number[] = [];
|
|
|
|
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
|
|
if (!document.body.classList.contains("public") && messageIds.length > 0) {
|
|
socket.emit("msg:preview:toggle", {
|
|
target: store.state.activeChannel?.channel.id,
|
|
messageIds: messageIds,
|
|
shown: true,
|
|
});
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
export default {input};
|