- tweak: Rework loading status
This commit is contained in:
@@ -23,13 +23,13 @@ public sealed partial class FavoriteServerListProvider : IServerListProvider, IS
|
||||
[GenerateProperty] private IServiceProvider ServiceProvider { get; }
|
||||
[GenerateProperty] private ServerViewContainer ServerViewContainer { get; }
|
||||
|
||||
private List<IFilterConsumer> _serverLists = [];
|
||||
private List<IListEntryModelView> _serverLists = [];
|
||||
private string[] rawServerLists = [];
|
||||
|
||||
public bool IsLoaded { get; private set; }
|
||||
public Action? OnLoaded { get; set; }
|
||||
public Action? Dirty { get; set; }
|
||||
public IEnumerable<IFilterConsumer> GetServers()
|
||||
public IEnumerable<IListEntryModelView> GetServers()
|
||||
{
|
||||
return _serverLists;
|
||||
}
|
||||
@@ -44,13 +44,13 @@ public sealed partial class FavoriteServerListProvider : IServerListProvider, IS
|
||||
IsLoaded = false;
|
||||
_serverLists.Clear();
|
||||
var servers = GetFavoriteEntries();
|
||||
|
||||
_serverLists.AddRange(
|
||||
servers.Select(s =>
|
||||
ServerViewContainer.Get(s.ToRobustUrl())
|
||||
)
|
||||
|
||||
var serverEntries = servers.Select(s =>
|
||||
ServerViewContainer.Get(s.ToRobustUrl())
|
||||
);
|
||||
|
||||
_serverLists.AddRange(serverEntries);
|
||||
|
||||
_serverLists.Add(new AddFavoriteButton(ServiceProvider));
|
||||
|
||||
IsLoaded = true;
|
||||
@@ -67,7 +67,7 @@ public sealed partial class FavoriteServerListProvider : IServerListProvider, IS
|
||||
var servers = GetFavoriteEntries();
|
||||
servers.Add(robustUrl.ToString());
|
||||
ConfigurationService.SetConfigValue(LauncherConVar.Favorites, servers.ToArray());
|
||||
ServerViewContainer.Get(robustUrl).IsFavorite = true;
|
||||
if(ServerViewContainer.Get(robustUrl) is IFavoriteEntryModelView favoriteView) favoriteView.IsFavorite = true;
|
||||
}
|
||||
|
||||
public void RemoveFavorite(ServerEntryModelView entryModelView)
|
||||
@@ -76,6 +76,13 @@ public sealed partial class FavoriteServerListProvider : IServerListProvider, IS
|
||||
servers.Remove(entryModelView.Address.ToString());
|
||||
ConfigurationService.SetConfigValue(LauncherConVar.Favorites, servers.ToArray());
|
||||
}
|
||||
|
||||
public void RemoveFavorite(RobustUrl url)
|
||||
{
|
||||
var servers = GetFavoriteEntries();
|
||||
servers.Remove(url.ToString());
|
||||
ConfigurationService.SetConfigValue(LauncherConVar.Favorites, servers.ToArray());
|
||||
}
|
||||
|
||||
private List<string> GetFavoriteEntries()
|
||||
{
|
||||
@@ -103,7 +110,7 @@ public sealed partial class FavoriteServerListProvider : IServerListProvider, IS
|
||||
private void InitialiseInDesignMode(){}
|
||||
}
|
||||
|
||||
public class AddFavoriteButton: Border, IFilterConsumer{
|
||||
public class AddFavoriteButton: Border, IListEntryModelView{
|
||||
|
||||
private Button _addFavoriteButton = new Button();
|
||||
public AddFavoriteButton(IServiceProvider serviceProvider)
|
||||
@@ -120,8 +127,5 @@ public class AddFavoriteButton: Border, IFilterConsumer{
|
||||
_addFavoriteButton.Content = "Add Favorite";
|
||||
Child = _addFavoriteButton;
|
||||
}
|
||||
|
||||
public void ProcessFilter(ServerFilter? serverFilter)
|
||||
{
|
||||
}
|
||||
public bool IsFavorite { get; set; }
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public sealed partial class HubServerListProvider : IServerListProvider
|
||||
public Action? OnLoaded { get; set; }
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
private readonly List<ServerEntryModelView> _servers = [];
|
||||
private readonly List<IListEntryModelView> _servers = [];
|
||||
private readonly List<Exception> _errors = [];
|
||||
|
||||
public HubServerListProvider With(string hubUrl)
|
||||
@@ -33,7 +33,7 @@ public sealed partial class HubServerListProvider : IServerListProvider
|
||||
return this;
|
||||
}
|
||||
|
||||
public IEnumerable<IFilterConsumer> GetServers()
|
||||
public IEnumerable<IListEntryModelView> GetServers()
|
||||
{
|
||||
return _servers;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Nebula.Launcher.ViewModels;
|
||||
using Nebula.Launcher.ViewModels.Pages;
|
||||
|
||||
namespace Nebula.Launcher.ServerListProviders;
|
||||
|
||||
@@ -9,7 +10,7 @@ public interface IServerListProvider
|
||||
public bool IsLoaded { get; }
|
||||
public Action? OnLoaded { get; set; }
|
||||
|
||||
public IEnumerable<IFilterConsumer> GetServers();
|
||||
public IEnumerable<IListEntryModelView> GetServers();
|
||||
public IEnumerable<Exception> GetErrors();
|
||||
|
||||
public void LoadServerList();
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Nebula.Launcher.Controls;
|
||||
using Nebula.Launcher.ViewModels;
|
||||
using Nebula.Launcher.ViewModels.Pages;
|
||||
|
||||
namespace Nebula.Launcher.ServerListProviders;
|
||||
|
||||
@@ -9,7 +10,7 @@ public sealed class TestServerList : IServerListProvider
|
||||
{
|
||||
public bool IsLoaded => true;
|
||||
public Action? OnLoaded { get; set; }
|
||||
public IEnumerable<IFilterConsumer> GetServers()
|
||||
public IEnumerable<IListEntryModelView> GetServers()
|
||||
{
|
||||
return [new ServerEntryModelView(),new ServerEntryModelView()];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user