show thingy topic right away

This commit is contained in:
ouwou 2024-04-23 22:14:14 -04:00
parent 870f05062a
commit 3dc8fa8e65
3 changed files with 19 additions and 3 deletions

View File

@ -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;
}

View File

@ -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>

View File

@ -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);
}