Skip to content

Commit

Permalink
show thingy topic right away
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed Apr 24, 2024
1 parent 870f050 commit 3dc8fa8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/discord/discord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/discord/discord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class DiscordClient {
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>
Expand Down
12 changes: 9 additions & 3 deletions src/windows/voice/voicewindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>");
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 3dc8fa8

Please sign in to comment.