Fix /collapse and /expand from interacting with the server in public mode (#4488)

Reported by xnaas on IRC
This commit is contained in:
Max Leiter 2022-02-18 12:21:17 -08:00 committed by GitHub
parent 66455f2c40
commit 551f85ea51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 33 deletions

View File

@ -22,7 +22,7 @@ function input() {
}
// Tell the server we're toggling so it remembers at page reload
if (messageIds.length > 0) {
if (!document.body.classList.contains("public") && messageIds.length > 0) {
socket.emit("msg:preview:toggle", {
target: store.state.activeChannel.channel.id,
messageIds: messageIds,

View File

@ -22,7 +22,7 @@ function input() {
}
// Tell the server we're toggling so it remembers at page reload
if (messageIds.length > 0) {
if (!document.body.classList.contains("public") && messageIds.length > 0) {
socket.emit("msg:preview:toggle", {
target: store.state.activeChannel.channel.id,
messageIds: messageIds,

View File

@ -503,8 +503,11 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
);
});
// In public mode only one client can be connected,
// so there's no need to handle msg:preview:toggle
if (!Helper.config.public) {
socket.on("msg:preview:toggle", (data) => {
if (!_.isPlainObject(data)) {
if (_.isPlainObject(data)) {
return;
}
@ -520,10 +523,12 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
for (const msgId of data.messageIds) {
const message = networkAndChan.chan.findMessage(msgId);
if (message) {
for (const preview of message.previews) {
preview.shown = newState;
}
}
}
return;
}
@ -540,6 +545,7 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
preview.shown = newState;
}
});
}
socket.on("mentions:get", () => {
socket.emit("mentions:list", client.mentions);