From 49a6e581375fdf0b5f5e82f981ca2d7cb419267f Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 13 Oct 2020 23:56:00 -0400 Subject: join/leave guild updates without reloading entire channel list --- components/channels.hpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'components/channels.hpp') diff --git a/components/channels.hpp b/components/channels.hpp index 8215133..8989669 100644 --- a/components/channels.hpp +++ b/components/channels.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "../discord/discord.hpp" @@ -13,16 +14,10 @@ public: bool IsHidden; Snowflake ID; std::unordered_set Children; + ChannelListRow *Parent = nullptr; - typedef sigc::signal type_signal_list_collapse; - typedef sigc::signal type_signal_list_uncollapse; - - type_signal_list_collapse signal_list_collapse(); - type_signal_list_uncollapse signal_list_uncollapse(); - -protected: - type_signal_list_collapse m_signal_list_collapse; - type_signal_list_uncollapse m_signal_list_uncollapse; + virtual void Collapse(); + virtual void Expand(); }; class ChannelListRowDMHeader : public ChannelListRow { @@ -67,6 +62,9 @@ class ChannelListRowCategory : public ChannelListRow { public: ChannelListRowCategory(const Channel *data); + virtual void Collapse(); + virtual void Expand(); + protected: Gtk::EventBox *m_ev; Gtk::Box *m_box; @@ -89,12 +87,18 @@ public: ChannelList(); Gtk::Widget *GetRoot() const; void UpdateListing(); + void UpdateNewGuild(Snowflake id); + void UpdateRemoveGuild(Snowflake id); void Clear(); protected: Gtk::ListBox *m_list; Gtk::ScrolledWindow *m_main; + void CollapseRow(ChannelListRow *row); + void ExpandRow(ChannelListRow *row); + void DeleteRow(ChannelListRow *row); + void on_row_activated(Gtk::ListBoxRow *row); int m_guild_count; @@ -115,6 +119,13 @@ protected: Glib::Dispatcher m_update_dispatcher; //mutable std::mutex m_update_mutex; //std::queue> m_update_queue; + + // i would use one map but in really old guilds there can be a channel w/ same id as the guild so this hacky shit has to do + std::unordered_map m_guild_id_to_row; + std::unordered_map m_id_to_row; + + void InsertGuildAt(Snowflake id, int pos); + void AddPrivateChannels(); // retard moment void UpdateListingInternal(); void AttachGuildMenuHandler(Gtk::ListBoxRow *row); -- cgit v1.2.3