Emit an event to clear history on all open clients

This commit is contained in:
Pavel Djundik 2020-02-28 17:01:17 +02:00
parent 44a8925b8c
commit c463d1ddd3
4 changed files with 19 additions and 6 deletions

View file

@ -147,12 +147,6 @@ export function generateChannelContextMenu($root, channel, network) {
return;
}
channel.messages = [];
channel.unread = 0;
channel.highlight = 0;
channel.firstUnread = 0;
channel.moreHistoryAvailable = false;
socket.emit("history:clear", {
target: channel.id,
});

View file

@ -0,0 +1,14 @@
"use strict";
import socket from "../socket";
import store from "../store";
socket.on("history:clear", function(data) {
const {channel} = store.getters.findChannel(data.target);
channel.messages = [];
channel.unread = 0;
channel.highlight = 0;
channel.firstUnread = 0;
channel.moreHistoryAvailable = false;
});

View file

@ -23,3 +23,4 @@ import "./sessions_list";
import "./configuration";
import "./changelog";
import "./setting";
import "./history_clear";

View file

@ -514,6 +514,10 @@ Client.prototype.clearHistory = function(data) {
target.chan.highlight = 0;
target.chan.firstUnread = 0;
client.emit("history:clear", {
target: target.chan.id,
});
if (!target.chan.isLoggable()) {
return;
}