Skip to content

Commit

Permalink
* Fix flicker in server list when switching servers. (#108)
Browse files Browse the repository at this point in the history
* Fix a bug where the scroll area of the server list is too large.
  • Loading branch information
iProgramMC committed Jun 13, 2024
1 parent 62906f7 commit ae848eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/discord/DiscordInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,13 +671,14 @@ void DiscordInstance::HandleRequest(NetRequest* pRequest)

m_CurrentChannel = 0;

GetFrontend()->RepaintGuildList();

// select the first one, if possible
Snowflake guildsf = 0;
if (m_guilds.size() > 0)
guildsf = m_guilds.front().m_snowflake;

OnSelectGuild(guildsf);

break;
}
case GUILD:
Expand Down Expand Up @@ -2093,6 +2094,7 @@ void DiscordInstance::HandleREADY(Json& j)
guildsf = m_CurrentGuild;
}

GetFrontend()->RepaintGuildList();
OnSelectGuild(guildsf);

// Doing this because the contents of all channels might be outdated.
Expand Down
8 changes: 4 additions & 4 deletions src/windows/GuildLister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ void GuildLister::UpdateSelected()

auto it = m_iconRects.find(m_selectedGuild);
if (it != m_iconRects.end()) {
InvalidateRect(m_hwnd, NULL, TRUE);
InvalidateRect(m_hwnd, &it->second, FALSE);
}

m_selectedGuild = GetDiscordInstance()->GetCurrentGuildID();
it = m_iconRects.find(m_selectedGuild);
if (it != m_iconRects.end()) {
InvalidateRect(m_hwnd, NULL, TRUE);
InvalidateRect(m_hwnd, &it->second, FALSE);
}
}

Expand Down Expand Up @@ -520,8 +520,8 @@ int GuildLister::GetScrollableHeight()
std::vector<Snowflake> sf;
GetDiscordInstance()->GetGuildIDs(sf, true);
//take out gap
int pfpSize = ScaleByDPI(PROFILE_PICTURE_SIZE_DEF + 12) + BORDER_SIZE * 2;
return sf.size() * pfpSize - (pfpSize - C_GUILD_GAP_HEIGHT);
int pfpSize = ScaleByDPI(PROFILE_PICTURE_SIZE_DEF + 12);
return sf.size() * pfpSize - pfpSize + C_GUILD_GAP_HEIGHT;
}

std::string MakeIconStringFromName(const std::string& name)
Expand Down

0 comments on commit ae848eb

Please sign in to comment.