hardlounge/client/js/commands/expand.ts

39 lines
768 B
TypeScript
Raw Normal View History

2019-11-16 17:24:03 +00:00
import socket from "../socket";
import {store} from "../store";
2019-11-16 17:24:03 +00:00
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;
2019-11-16 17:24:03 +00:00
}
export default {input};