Skip to content

Commit e6af9ab

Browse files
committed
1 parent 0f4031f commit e6af9ab

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,9 @@ public async Task RefreshSubscriptions()
188188
{
189189
SubItems.Add(item);
190190
}
191-
if (_subIndexId != null && SubItems.FirstOrDefault(t => t.Id == _subIndexId) != null)
192-
{
193-
SelectedSub = SubItems.FirstOrDefault(t => t.Id == _subIndexId);
194-
}
195-
else
196-
{
197-
SelectedSub = SubItems.First();
198-
}
191+
SelectedSub = (_config.SubIndexId.IsNotEmpty()
192+
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
193+
: null) ?? SubItems.LastOrDefault();
199194
}
200195

201196
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)

v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,9 @@ private async Task RefreshSubscriptions()
391391
{
392392
SubItems.Add(item);
393393
}
394-
if (_config.SubIndexId != null && SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId) != null)
395-
{
396-
SelectedSub = SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId);
397-
}
398-
else
399-
{
400-
SelectedSub = SubItems.First();
401-
}
394+
SelectedSub = (_config.SubIndexId.IsNotEmpty()
395+
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
396+
: null) ?? SubItems.LastOrDefault();
402397
}
403398

404399
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)

0 commit comments

Comments
 (0)