diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/discord/discord.cpp | 9 | ||||
-rw-r--r-- | src/discord/discord.hpp | 1 | ||||
-rw-r--r-- | src/windows/voice/voicewindow.cpp | 12 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index b3f8ca6..c54583a 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -358,6 +358,14 @@ std::optional<WebhookMessageData> DiscordClient::GetWebhookMessageData(Snowflake return m_store.GetWebhookMessage(message_id); } +std::optional<StageInstance> DiscordClient::GetStageInstanceFromChannel(Snowflake channel_id) const { + const auto iter1 = m_channel_to_stage_instance.find(channel_id); + if (iter1 == m_channel_to_stage_instance.end()) return {}; + const auto iter2 = m_stage_instances.find(iter1->second); + if (iter2 == m_stage_instances.end()) return {}; + return iter2->second; +} + bool DiscordClient::IsThreadJoined(Snowflake thread_id) const { return std::find(m_joined_threads.begin(), m_joined_threads.end(), thread_id) != m_joined_threads.end(); } @@ -1722,6 +1730,7 @@ void DiscordClient::ProcessNewGuild(GuildData &guild) { if (guild.StageInstances.has_value()) { for (const auto &stage : *guild.StageInstances) { + spdlog::get("discord")->debug("storing stage {} in channel {}", stage.ID, stage.ChannelID); m_stage_instances[stage.ID] = stage; m_channel_to_stage_instance[stage.ChannelID] = stage.ID; } diff --git a/src/discord/discord.hpp b/src/discord/discord.hpp index 44a7328..eca25a6 100644 --- a/src/discord/discord.hpp +++ b/src/discord/discord.hpp @@ -65,6 +65,7 @@ public: void GetArchivedPrivateThreads(Snowflake channel_id, const sigc::slot<void(DiscordError, const ArchivedThreadsResponseData &)> &callback); std::vector<Snowflake> GetChildChannelIDs(Snowflake parent_id) const; std::optional<WebhookMessageData> GetWebhookMessageData(Snowflake message_id) const; + std::optional<StageInstance> GetStageInstanceFromChannel(Snowflake channel_id) const; // get ids of given list of members for who we do not have the member data template<typename Iter> diff --git a/src/windows/voice/voicewindow.cpp b/src/windows/voice/voicewindow.cpp index 5e91aad..8c4eb2c 100644 --- a/src/windows/voice/voicewindow.cpp +++ b/src/windows/voice/voicewindow.cpp @@ -181,6 +181,14 @@ VoiceWindow::VoiceWindow(Snowflake channel_id) combos_combos->pack_start(m_playback_combo); combos_combos->pack_start(m_capture_combo); + if (const auto instance = discord.GetStageInstanceFromChannel(channel_id); instance.has_value()) { + printf("%s\n", instance->Topic.c_str()); + m_TMP_stagelabel.show(); + m_TMP_stagelabel.set_markup("<span foreground='green'>" + instance->Topic + "</span>"); + } else { + m_TMP_stagelabel.hide(); + } + discord.signal_stage_instance_create().connect(sigc::track_obj([this](const StageInstance &instance) { m_TMP_stagelabel.show(); m_TMP_stagelabel.set_markup("<span foreground='green'>" + instance.Topic + "</span>"); @@ -218,9 +226,7 @@ VoiceWindow::VoiceWindow(Snowflake channel_id) m_main.pack_start(*combos_container, false, true, 2); add(m_main); show_all_children(); - - m_TMP_stagelabel.hide(); - + Glib::signal_timeout().connect(sigc::mem_fun(*this, &VoiceWindow::UpdateVoiceMeters), 40); } |