thelounge/client/js/commands/expand.ts
Reto Brunner 3fbbc39cd6 client/commands: statically import commands
Dynamic imports won't work very well with modules and we don't
really need them, it's just there to save us an import statement.

Let's flip this to a static version.
2024-05-04 12:29:57 +02:00

36 lines
771 B
TypeScript

import socket from "../socket";
import {store} from "../store";
export function input(): boolean {
if (!store.state.activeChannel) {
return false;
}
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;
}