clear messages on disconnect
This commit is contained in:
@@ -116,6 +116,12 @@ void ChatWindow::AddNewMessage(Snowflake id) {
|
|||||||
m_new_message_dispatch.emit();
|
m_new_message_dispatch.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatWindow::ClearMessages() {
|
||||||
|
std::scoped_lock<std::mutex> guard(m_update_mutex);
|
||||||
|
m_message_set_queue.push(std::unordered_set<const MessageData *>());
|
||||||
|
m_message_set_dispatch.emit();
|
||||||
|
}
|
||||||
|
|
||||||
void ChatWindow::ScrollToBottom() {
|
void ChatWindow::ScrollToBottom() {
|
||||||
auto x = m_scroll->get_vadjustment();
|
auto x = m_scroll->get_vadjustment();
|
||||||
x->set_value(x->get_upper());
|
x->set_value(x->get_upper());
|
||||||
|
@@ -16,6 +16,7 @@ public:
|
|||||||
Snowflake GetActiveChannel() const;
|
Snowflake GetActiveChannel() const;
|
||||||
void SetMessages(std::unordered_set<const MessageData *> msgs);
|
void SetMessages(std::unordered_set<const MessageData *> msgs);
|
||||||
void AddNewMessage(Snowflake id);
|
void AddNewMessage(Snowflake id);
|
||||||
|
void ClearMessages();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ScrollToBottom();
|
void ScrollToBottom();
|
||||||
|
@@ -74,19 +74,17 @@ MainWindow::MainWindow()
|
|||||||
void MainWindow::UpdateComponents() {
|
void MainWindow::UpdateComponents() {
|
||||||
bool discord_active = m_abaddon->IsDiscordActive();
|
bool discord_active = m_abaddon->IsDiscordActive();
|
||||||
|
|
||||||
// menu
|
|
||||||
// Connect
|
|
||||||
std::string token = m_abaddon->GetDiscordToken();
|
std::string token = m_abaddon->GetDiscordToken();
|
||||||
m_menu_discord_connect.set_sensitive(token.size() > 0 && !discord_active);
|
m_menu_discord_connect.set_sensitive(token.size() > 0 && !discord_active);
|
||||||
|
|
||||||
// Disconnect
|
|
||||||
m_menu_discord_disconnect.set_sensitive(discord_active);
|
m_menu_discord_disconnect.set_sensitive(discord_active);
|
||||||
|
|
||||||
// channel listing
|
if (!discord_active) {
|
||||||
if (!discord_active)
|
|
||||||
m_channel_list.ClearListing();
|
m_channel_list.ClearListing();
|
||||||
else
|
m_chat.ClearMessages();
|
||||||
|
} else {
|
||||||
UpdateChannelListing();
|
UpdateChannelListing();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::UpdateChannelListing() {
|
void MainWindow::UpdateChannelListing() {
|
||||||
|
Reference in New Issue
Block a user