forked from OpenGamers/abaddon
handle change of mute state for guilds
This commit is contained in:
@@ -186,6 +186,8 @@ ChannelList::ChannelList()
|
|||||||
discord.signal_message_ack().connect(sigc::mem_fun(*this, &ChannelList::OnMessageAck));
|
discord.signal_message_ack().connect(sigc::mem_fun(*this, &ChannelList::OnMessageAck));
|
||||||
discord.signal_channel_muted().connect(sigc::mem_fun(*this, &ChannelList::OnChannelMute));
|
discord.signal_channel_muted().connect(sigc::mem_fun(*this, &ChannelList::OnChannelMute));
|
||||||
discord.signal_channel_unmuted().connect(sigc::mem_fun(*this, &ChannelList::OnChannelUnmute));
|
discord.signal_channel_unmuted().connect(sigc::mem_fun(*this, &ChannelList::OnChannelUnmute));
|
||||||
|
discord.signal_guild_muted().connect(sigc::mem_fun(*this, &ChannelList::OnGuildMute));
|
||||||
|
discord.signal_guild_unmuted().connect(sigc::mem_fun(*this, &ChannelList::OnGuildUnmute));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelList::UsePanedHack(Gtk::Paned &paned) {
|
void ChannelList::UsePanedHack(Gtk::Paned &paned) {
|
||||||
@@ -392,6 +394,16 @@ void ChannelList::OnChannelUnmute(Snowflake id) {
|
|||||||
m_model->row_changed(m_model->get_path(iter), iter);
|
m_model->row_changed(m_model->get_path(iter), iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChannelList::OnGuildMute(Snowflake id) {
|
||||||
|
if (auto iter = GetIteratorForGuildFromID(id))
|
||||||
|
m_model->row_changed(m_model->get_path(iter), iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChannelList::OnGuildUnmute(Snowflake id) {
|
||||||
|
if (auto iter = GetIteratorForGuildFromID(id))
|
||||||
|
m_model->row_changed(m_model->get_path(iter), iter);
|
||||||
|
}
|
||||||
|
|
||||||
// create a temporary channel row for non-joined threads
|
// create a temporary channel row for non-joined threads
|
||||||
// and delete them when the active channel switches off of them if still not joined
|
// and delete them when the active channel switches off of them if still not joined
|
||||||
void ChannelList::SetActiveChannel(Snowflake id) {
|
void ChannelList::SetActiveChannel(Snowflake id) {
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ protected:
|
|||||||
void DeleteThreadRow(Snowflake id);
|
void DeleteThreadRow(Snowflake id);
|
||||||
void OnChannelMute(Snowflake id);
|
void OnChannelMute(Snowflake id);
|
||||||
void OnChannelUnmute(Snowflake id);
|
void OnChannelUnmute(Snowflake id);
|
||||||
|
void OnGuildMute(Snowflake id);
|
||||||
|
void OnGuildUnmute(Snowflake id);
|
||||||
|
|
||||||
void OnThreadJoined(Snowflake id);
|
void OnThreadJoined(Snowflake id);
|
||||||
void OnThreadRemoved(Snowflake id);
|
void OnThreadRemoved(Snowflake id);
|
||||||
|
|||||||
@@ -1919,6 +1919,26 @@ void DiscordClient::HandleGatewayUserGuildSettingsUpdate(const GatewayMessage &m
|
|||||||
const auto channels = GetChannelsInGuild(data.Settings.GuildID);
|
const auto channels = GetChannelsInGuild(data.Settings.GuildID);
|
||||||
std::set<Snowflake> now_muted_channels;
|
std::set<Snowflake> now_muted_channels;
|
||||||
const auto now = Snowflake::FromNow();
|
const auto now = Snowflake::FromNow();
|
||||||
|
|
||||||
|
const bool was_muted = IsGuildMuted(data.Settings.GuildID);
|
||||||
|
bool now_muted = false;
|
||||||
|
if (data.Settings.Muted) {
|
||||||
|
if (data.Settings.MuteConfig.EndTime.has_value()) {
|
||||||
|
const auto end = Snowflake::FromISO8601(*data.Settings.MuteConfig.EndTime);
|
||||||
|
if (end.IsValid() && end > now)
|
||||||
|
now_muted = true;
|
||||||
|
} else {
|
||||||
|
now_muted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (was_muted && !now_muted) {
|
||||||
|
m_muted_guilds.erase(data.Settings.GuildID);
|
||||||
|
m_signal_guild_unmuted.emit(data.Settings.GuildID);
|
||||||
|
} else if (!was_muted && now_muted) {
|
||||||
|
m_muted_guilds.insert(data.Settings.GuildID);
|
||||||
|
m_signal_guild_muted.emit(data.Settings.GuildID);
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto &override : data.Settings.ChannelOverrides) {
|
for (const auto &override : data.Settings.ChannelOverrides) {
|
||||||
if (override.Muted) {
|
if (override.Muted) {
|
||||||
if (override.MuteConfig.EndTime.has_value()) {
|
if (override.MuteConfig.EndTime.has_value()) {
|
||||||
@@ -2575,6 +2595,14 @@ DiscordClient::type_signal_channel_unmuted DiscordClient::signal_channel_unmuted
|
|||||||
return m_signal_channel_unmuted;
|
return m_signal_channel_unmuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiscordClient::type_signal_guild_muted DiscordClient::signal_guild_muted() {
|
||||||
|
return m_signal_guild_muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
DiscordClient::type_signal_guild_unmuted DiscordClient::signal_guild_unmuted() {
|
||||||
|
return m_signal_guild_unmuted;
|
||||||
|
}
|
||||||
|
|
||||||
DiscordClient::type_signal_message_send_fail DiscordClient::signal_message_send_fail() {
|
DiscordClient::type_signal_message_send_fail DiscordClient::signal_message_send_fail() {
|
||||||
return m_signal_message_send_fail;
|
return m_signal_message_send_fail;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -372,6 +372,8 @@ public:
|
|||||||
typedef sigc::signal<void, Message> type_signal_message_sent;
|
typedef sigc::signal<void, Message> type_signal_message_sent;
|
||||||
typedef sigc::signal<void, Snowflake> type_signal_channel_muted;
|
typedef sigc::signal<void, Snowflake> type_signal_channel_muted;
|
||||||
typedef sigc::signal<void, Snowflake> type_signal_channel_unmuted;
|
typedef sigc::signal<void, Snowflake> type_signal_channel_unmuted;
|
||||||
|
typedef sigc::signal<void, Snowflake> type_signal_guild_muted;
|
||||||
|
typedef sigc::signal<void, Snowflake> type_signal_guild_unmuted;
|
||||||
|
|
||||||
typedef sigc::signal<void, std::string /* nonce */, float /* retry_after */> type_signal_message_send_fail; // retry after param will be 0 if it failed for a reason that isnt slowmode
|
typedef sigc::signal<void, std::string /* nonce */, float /* retry_after */> type_signal_message_send_fail; // retry after param will be 0 if it failed for a reason that isnt slowmode
|
||||||
typedef sigc::signal<void, bool, GatewayCloseCode> type_signal_disconnected; // bool true if reconnecting
|
typedef sigc::signal<void, bool, GatewayCloseCode> type_signal_disconnected; // bool true if reconnecting
|
||||||
@@ -422,6 +424,8 @@ public:
|
|||||||
type_signal_message_sent signal_message_sent();
|
type_signal_message_sent signal_message_sent();
|
||||||
type_signal_channel_muted signal_channel_muted();
|
type_signal_channel_muted signal_channel_muted();
|
||||||
type_signal_channel_unmuted signal_channel_unmuted();
|
type_signal_channel_unmuted signal_channel_unmuted();
|
||||||
|
type_signal_guild_muted signal_guild_muted();
|
||||||
|
type_signal_guild_unmuted signal_guild_unmuted();
|
||||||
type_signal_message_send_fail signal_message_send_fail();
|
type_signal_message_send_fail signal_message_send_fail();
|
||||||
type_signal_disconnected signal_disconnected();
|
type_signal_disconnected signal_disconnected();
|
||||||
type_signal_connected signal_connected();
|
type_signal_connected signal_connected();
|
||||||
@@ -472,6 +476,8 @@ protected:
|
|||||||
type_signal_message_sent m_signal_message_sent;
|
type_signal_message_sent m_signal_message_sent;
|
||||||
type_signal_channel_muted m_signal_channel_muted;
|
type_signal_channel_muted m_signal_channel_muted;
|
||||||
type_signal_channel_unmuted m_signal_channel_unmuted;
|
type_signal_channel_unmuted m_signal_channel_unmuted;
|
||||||
|
type_signal_guild_muted m_signal_guild_muted;
|
||||||
|
type_signal_guild_unmuted m_signal_guild_unmuted;
|
||||||
type_signal_message_send_fail m_signal_message_send_fail;
|
type_signal_message_send_fail m_signal_message_send_fail;
|
||||||
type_signal_disconnected m_signal_disconnected;
|
type_signal_disconnected m_signal_disconnected;
|
||||||
type_signal_connected m_signal_connected;
|
type_signal_connected m_signal_connected;
|
||||||
|
|||||||
Reference in New Issue
Block a user