| 85 | } |
| 86 | |
| 87 | void QuickSwitcher::OnUpdateQuery(HWND hWnd, const std::string& query) |
| 88 | { |
| 89 | std::vector<QuickMatch> foundChannels = GetDiscordInstance()->Search(query); |
| 90 | |
| 91 | if (query.empty()) |
| 92 | SetDlgItemText(hWnd, IDC_QUICK_GROUP, TEXT("Previous Channels")); |
| 93 | else switch (query[0]) |
| 94 | { |
| 95 | case '@': SetDlgItemText(hWnd, IDC_QUICK_GROUP, TEXT("Searching Direct Messages")); break; |
| 96 | case '!': SetDlgItemText(hWnd, IDC_QUICK_GROUP, TEXT("Searching Voice Channels")); break; |
| 97 | case '#': SetDlgItemText(hWnd, IDC_QUICK_GROUP, TEXT("Searching Text Channels")); break; |
| 98 | case '*': SetDlgItemText(hWnd, IDC_QUICK_GROUP, TEXT("Searching Servers")); break; |
| 99 | default: SetDlgItemText(hWnd, IDC_QUICK_GROUP, TEXT("Search Results")); break; |
| 100 | } |
| 101 | |
| 102 | HWND hList = GetDlgItem(hWnd, IDC_CHANNEL_LIST); |
| 103 | |
| 104 | if (SupportsDialogEx()) |
| 105 | ListView_DeleteAllItems(hList); |
| 106 | else |
| 107 | ListBox_ResetContent(hList); |
| 108 | |
| 109 | g_qsItems.clear(); |
| 110 | |
| 111 | for (auto& match : foundChannels) |
| 112 | { |
| 113 | std::string name = ""; |
| 114 | std::string guildName = ""; |
| 115 | std::string categName = ""; |
| 116 | std::string namePfx = ""; |
| 117 | |
| 118 | int iconIdx = ICN_GUILD; |
| 119 | Snowflake guildID = 0; |
| 120 | |
| 121 | if (match.IsChannel()) |
| 122 | { |
| 123 | Channel* pChan = GetDiscordInstance()->GetChannel(match.Id()); |
| 124 | |
| 125 | if (!pChan) { |
| 126 | DbgPrintW("Error, can't find channel %lld which DiscordInstance returned?", match.Id()); |
| 127 | continue; |
| 128 | } |
| 129 | |
| 130 | iconIdx = GetIconFromChannel(pChan); |
| 131 | name = pChan->m_name; |
| 132 | namePfx = pChan->GetTypeSymbol(); |
| 133 | |
| 134 | Guild* pGuild = GetDiscordInstance()->GetGuild(pChan->m_parentGuild); |
| 135 | if (!pGuild) { |
| 136 | DbgPrintW("Error, can't find guild %lld for channel %lld (%s)", pChan->m_parentGuild, pChan->m_snowflake, pChan->m_name.c_str()); |
| 137 | continue; |
| 138 | } |
| 139 | |
| 140 | guildName = pGuild->m_name; |
| 141 | guildID = pChan->m_parentGuild; |
| 142 | |
| 143 | Channel* pCateg = pGuild->GetChannel(pChan->m_parentCateg); |
| 144 | if (pCateg && pCateg != pChan) |
nothing calls this directly
no test coverage detected