- tweak: loading popup thinks
* - tweak: change loading handle logic * - tweak: beautify loading thinks * - fix: speed thinks while downloading
This commit is contained in:
@@ -32,6 +32,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
[ObservableProperty] private bool _isLogged;
|
||||
[ObservableProperty] private bool _doRetryAuth;
|
||||
[ObservableProperty] private AuthServerCredentials _authItemSelect;
|
||||
[ObservableProperty] private string _authServerName;
|
||||
|
||||
private bool _isProfilesEmpty;
|
||||
[GenerateProperty] private PopupMessageService PopupMessageService { get; }
|
||||
@@ -68,7 +69,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
public void DoAuth(string? code = null)
|
||||
{
|
||||
var message = ViewHelperService.GetViewModel<InfoPopupViewModel>();
|
||||
message.InfoText = LocalisationService.GetString("auth-processing");
|
||||
message.InfoText = LocalizationService.GetString("auth-processing");
|
||||
message.IsInfoClosable = false;
|
||||
PopupMessageService.Popup(message);
|
||||
|
||||
@@ -95,7 +96,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = new Exception(LocalisationService.GetString("auth-error"), ex);
|
||||
exception = new Exception(LocalizationService.GetString("auth-error"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,19 +129,19 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
_logger.Log("TFA required");
|
||||
break;
|
||||
case AuthenticateDenyCode.InvalidCredentials:
|
||||
PopupError(LocalisationService.GetString("auth-invalid-credentials"), e);
|
||||
PopupError(LocalizationService.GetString("auth-invalid-credentials"), e);
|
||||
break;
|
||||
case AuthenticateDenyCode.AccountLocked:
|
||||
PopupError(LocalisationService.GetString("auth-account-locked"), e);
|
||||
PopupError(LocalizationService.GetString("auth-account-locked"), e);
|
||||
break;
|
||||
case AuthenticateDenyCode.AccountUnconfirmed:
|
||||
PopupError(LocalisationService.GetString("auth-account-unconfirmed"), e);
|
||||
PopupError(LocalizationService.GetString("auth-account-unconfirmed"), e);
|
||||
break;
|
||||
case AuthenticateDenyCode.None:
|
||||
PopupError(LocalisationService.GetString("auth-none"),e);
|
||||
PopupError(LocalizationService.GetString("auth-none"),e);
|
||||
break;
|
||||
default:
|
||||
PopupError(LocalisationService.GetString("auth-error-fuck"), e);
|
||||
PopupError(LocalizationService.GetString("auth-error-fuck"), e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -150,46 +151,46 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
switch (e.HttpRequestError)
|
||||
{
|
||||
case HttpRequestError.ConnectionError:
|
||||
PopupError(LocalisationService.GetString("auth-connection-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-connection-error"), e);
|
||||
DoRetryAuth = true;
|
||||
break;
|
||||
case HttpRequestError.NameResolutionError:
|
||||
PopupError(LocalisationService.GetString("auth-name-resolution-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-name-resolution-error"), e);
|
||||
DoRetryAuth = true;
|
||||
break;
|
||||
case HttpRequestError.SecureConnectionError:
|
||||
PopupError(LocalisationService.GetString("auth-secure-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-secure-error"), e);
|
||||
DoRetryAuth = true;
|
||||
break;
|
||||
case HttpRequestError.UserAuthenticationError:
|
||||
PopupError(LocalisationService.GetString("auth-user-authentication-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-user-authentication-error"), e);
|
||||
break;
|
||||
case HttpRequestError.Unknown:
|
||||
PopupError(LocalisationService.GetString("auth-unknown"), e);
|
||||
PopupError(LocalizationService.GetString("auth-unknown"), e);
|
||||
break;
|
||||
case HttpRequestError.HttpProtocolError:
|
||||
PopupError(LocalisationService.GetString("auth-http-protocol-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-http-protocol-error"), e);
|
||||
break;
|
||||
case HttpRequestError.ExtendedConnectNotSupported:
|
||||
PopupError(LocalisationService.GetString("auth-extended-connect-not-support"), e);
|
||||
PopupError(LocalizationService.GetString("auth-extended-connect-not-support"), e);
|
||||
break;
|
||||
case HttpRequestError.VersionNegotiationError:
|
||||
PopupError(LocalisationService.GetString("auth-version-negotiation-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-version-negotiation-error"), e);
|
||||
break;
|
||||
case HttpRequestError.ProxyTunnelError:
|
||||
PopupError(LocalisationService.GetString("auth-proxy-tunnel-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-proxy-tunnel-error"), e);
|
||||
break;
|
||||
case HttpRequestError.InvalidResponse:
|
||||
PopupError(LocalisationService.GetString("auth-invalid-response"), e);
|
||||
PopupError(LocalizationService.GetString("auth-invalid-response"), e);
|
||||
break;
|
||||
case HttpRequestError.ResponseEnded:
|
||||
PopupError(LocalisationService.GetString("auth-response-ended"), e);
|
||||
PopupError(LocalizationService.GetString("auth-response-ended"), e);
|
||||
break;
|
||||
case HttpRequestError.ConfigurationLimitExceeded:
|
||||
PopupError(LocalisationService.GetString("auth-configuration-limit-exceeded"), e);
|
||||
PopupError(LocalizationService.GetString("auth-configuration-limit-exceeded"), e);
|
||||
break;
|
||||
default:
|
||||
var authError = new Exception(LocalisationService.GetString("auth-error"), e);
|
||||
var authError = new Exception(LocalizationService.GetString("auth-error"), e);
|
||||
_logger.Error(authError);
|
||||
PopupMessageService.Popup(authError);
|
||||
break;
|
||||
@@ -245,7 +246,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
private async Task ReadAuthConfig()
|
||||
{
|
||||
var message = ViewHelperService.GetViewModel<InfoPopupViewModel>();
|
||||
message.InfoText = LocalisationService.GetString("auth-config-read");
|
||||
message.InfoText = LocalizationService.GetString("auth-config-read");
|
||||
message.IsInfoClosable = false;
|
||||
PopupMessageService.Popup(message);
|
||||
|
||||
@@ -318,7 +319,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var unexpectedError = new Exception(LocalisationService.GetString("auth-error"), e);
|
||||
var unexpectedError = new Exception(LocalizationService.GetString("auth-error"), e);
|
||||
_logger.Error(unexpectedError);
|
||||
return authTokenCredentials;
|
||||
}
|
||||
@@ -345,7 +346,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
|
||||
private void PopupError(string message, Exception e)
|
||||
{
|
||||
message = LocalisationService.GetString("auth-error-occured") + message;
|
||||
message = LocalizationService.GetString("auth-error-occured") + message;
|
||||
_logger.Error(new Exception(message, e));
|
||||
|
||||
var messageView = ViewHelperService.GetViewModel<InfoPopupViewModel>();
|
||||
@@ -385,7 +386,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
var message = accountInfoViewModel.ViewHelperService.GetViewModel<InfoPopupViewModel>();
|
||||
message.InfoText = LocalisationService.GetString("auth-try-auth-config");
|
||||
message.InfoText = LocalizationService.GetString("auth-try-auth-config");
|
||||
message.IsInfoClosable = false;
|
||||
accountInfoViewModel.PopupMessageService.Popup(message);
|
||||
|
||||
@@ -423,7 +424,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
{
|
||||
accountInfoViewModel.CurrentLogin = currProfile.Login;
|
||||
accountInfoViewModel.CurrentAuthServer = currProfile.AuthServer;
|
||||
var unexpectedError = new Exception(LocalisationService.GetString("auth-error"), ex);
|
||||
var unexpectedError = new Exception(LocalizationService.GetString("auth-error"), ex);
|
||||
accountInfoViewModel._logger.Error(unexpectedError);
|
||||
accountInfoViewModel.PopupMessageService.Popup(unexpectedError);
|
||||
errorRun = true;
|
||||
@@ -436,6 +437,8 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
accountInfoViewModel.IsLogged = true;
|
||||
|
||||
accountInfoViewModel.AuthServerName = accountInfoViewModel.GetServerAuthName(currProfile.AuthServer);
|
||||
|
||||
return currProfile;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public partial class ConfigurationViewModel : ViewModelBase
|
||||
using var loader = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||
loader.LoadingName = "Removing content";
|
||||
PopupService.Popup(loader);
|
||||
ContentService.RemoveAllContent(loader, CancellationService.Token);
|
||||
ContentService.RemoveAllContent(loader.CreateLoadingContext(), CancellationService.Token);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase, IContentHol
|
||||
[GenerateProperty] private FileService FileService { get; } = default!;
|
||||
[GenerateProperty] private PopupMessageService PopupService { get; } = default!;
|
||||
[GenerateProperty] private IServiceProvider ServiceProvider { get; }
|
||||
[GenerateProperty] private CancellationService CancellationService { get; set; } = default!;
|
||||
[GenerateProperty, DesignConstruct] private ViewHelperService ViewHelperService { get; } = default!;
|
||||
|
||||
|
||||
@@ -57,7 +58,11 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase, IContentHol
|
||||
loading.LoadingName = "Unpacking entry";
|
||||
PopupService.Popup(loading);
|
||||
|
||||
Task.Run(() => ContentService.Unpack(serverEntry.FileApi, myTempDir, loading));
|
||||
Task.Run(() =>
|
||||
{
|
||||
ContentService.Unpack(serverEntry.FileApi, myTempDir, loading.CreateLoadingContext());
|
||||
loading.Dispose();
|
||||
});
|
||||
ExplorerHelper.OpenFolder(tmpDir);
|
||||
}
|
||||
|
||||
@@ -74,7 +79,7 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase, IContentHol
|
||||
{
|
||||
var cur = ServiceProvider.GetService<ServerFolderContentEntry>()!;
|
||||
cur.Init(this, ServerText.ToRobustUrl());
|
||||
var curContent = cur.Go(new ContentPath(SearchText));
|
||||
var curContent = cur.Go(new ContentPath(SearchText), CancellationService.Token);
|
||||
if(curContent == null)
|
||||
throw new NullReferenceException($"{SearchText} not found in {ServerText}");
|
||||
|
||||
@@ -144,11 +149,11 @@ public interface IContentEntry
|
||||
public string IconPath { get; }
|
||||
public ContentPath FullPath => Parent?.FullPath.With(Name) ?? new ContentPath(Name);
|
||||
|
||||
public IContentEntry? Go(ContentPath path);
|
||||
public IContentEntry? Go(ContentPath path, CancellationToken cancellationToken);
|
||||
|
||||
public void GoCurrent()
|
||||
{
|
||||
var entry = Go(ContentPath.Empty);
|
||||
var entry = Go(ContentPath.Empty, CancellationToken.None);
|
||||
if(entry is not null) Holder.CurrentEntry = entry;
|
||||
}
|
||||
|
||||
@@ -178,7 +183,7 @@ public sealed class LazyContentEntry : IContentEntry
|
||||
_lazyEntry = entry;
|
||||
_lazyEntryInit = lazyEntryInit;
|
||||
}
|
||||
public IContentEntry? Go(ContentPath path)
|
||||
public IContentEntry? Go(ContentPath path, CancellationToken cancellationToken)
|
||||
{
|
||||
_lazyEntryInit?.Invoke();
|
||||
return _lazyEntry;
|
||||
@@ -196,13 +201,13 @@ public sealed class ExtContentExecutor
|
||||
_decompilerService = decompilerService;
|
||||
}
|
||||
|
||||
public bool TryExecute(RobustManifestItem manifestItem)
|
||||
public bool TryExecute(RobustManifestItem manifestItem, CancellationToken cancellationToken)
|
||||
{
|
||||
var ext = Path.GetExtension(manifestItem.Path);
|
||||
|
||||
if (ext == ".dll")
|
||||
{
|
||||
_decompilerService.OpenServerDecompiler(_root.ServerUrl);
|
||||
_decompilerService.OpenServerDecompiler(_root.ServerUrl, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -231,9 +236,9 @@ public sealed partial class ManifestContentEntry : IContentEntry
|
||||
_extContentExecutor = executor;
|
||||
}
|
||||
|
||||
public IContentEntry? Go(ContentPath path)
|
||||
public IContentEntry? Go(ContentPath path, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_extContentExecutor.TryExecute(_manifestItem))
|
||||
if (_extContentExecutor.TryExecute(_manifestItem, cancellationToken))
|
||||
return null;
|
||||
|
||||
var ext = Path.GetExtension(_manifestItem.Path);
|
||||
@@ -319,7 +324,7 @@ public sealed partial class ServerFolderContentEntry : BaseFolderContentEntry
|
||||
{
|
||||
CreateContent(new ContentPath(path), item);
|
||||
}
|
||||
|
||||
|
||||
IsLoading = false;
|
||||
loading.Dispose();
|
||||
});
|
||||
@@ -433,11 +438,11 @@ public abstract class BaseFolderContentEntry : ViewModelBase, IContentEntry
|
||||
public IContentEntry? Parent { get; set; }
|
||||
public string? Name { get; private set; }
|
||||
|
||||
public IContentEntry? Go(ContentPath path)
|
||||
public IContentEntry? Go(ContentPath path, CancellationToken cancellationToken)
|
||||
{
|
||||
if (path.IsEmpty()) return this;
|
||||
if (_childs.TryGetValue(path.GetNext(), out var child))
|
||||
return child.Go(path);
|
||||
return child.Go(path, cancellationToken);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public partial class ServerOverviewModel : ViewModelBase
|
||||
tempItems.Add(new ServerListTabTemplate(ServiceProvider.GetService<HubServerListProvider>()!.With(record.MainUrl), record.Name));
|
||||
}
|
||||
|
||||
tempItems.Add(new ServerListTabTemplate(FavoriteServerListProvider, "Favorite"));
|
||||
tempItems.Add(new ServerListTabTemplate(FavoriteServerListProvider, LocalizationService.GetString("tab-favorite")));
|
||||
|
||||
Items = new ObservableCollection<ServerListTabTemplate>(tempItems);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user