Skip to content

Commit b7951b9

Browse files
committed
fix: server list auto select first item
1 parent 40316c2 commit b7951b9

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

app/src/activity/server_list.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,12 @@ void ServerList::onContentAvailable() {
157157

158158
void ServerList::willAppear(bool resetState) {
159159
auto list = AppConfig::instance().getServers();
160-
if (list.empty()) {
161-
this->tabFrame->setTabAttachedView(new ServerAdd());
162-
return;
163-
}
160+
ServerCell* item = nullptr;
161+
std::string url = AppConfig::instance().getUrl();
164162
this->sidebarServers->clearViews();
165163

166164
for (auto& s : list) {
167-
ServerCell* item = new ServerCell(s);
165+
item = new ServerCell(s);
168166
item->getFocusEvent()->subscribe([this, s](brls::View* view) {
169167
this->setActive(view);
170168
this->onServer(s);
@@ -183,13 +181,20 @@ void ServerList::willAppear(bool resetState) {
183181
return true;
184182
});
185183

186-
if (s.urls.front() == AppConfig::instance().getUrl()) {
187-
item->setActive(true);
188-
this->onServer(s);
184+
if (s.urls.size() > 0) {
185+
if (url.empty()) {
186+
url = s.urls.front();
187+
}
188+
if (s.urls.front() == url) {
189+
item->setActive(true);
190+
this->onServer(s);
191+
}
189192
}
190193

191194
this->sidebarServers->addView(item);
192195
}
196+
197+
if (!item) this->tabFrame->setTabAttachedView(new ServerAdd());
193198
}
194199

195200
void ServerList::onServer(const AppServer& s) {

0 commit comments

Comments
 (0)