diff --git a/Blacklight.sln.DotSettings.user b/Blacklight.sln.DotSettings.user index 25b17d78d07ae681d6cb60e803133ac7d7bc4313..6afa4c6e38a77283682f0bf60cc04f1f9bb21deb 100644 --- a/Blacklight.sln.DotSettings.user +++ b/Blacklight.sln.DotSettings.user @@ -1,8 +1,12 @@ <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> + <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003A020002A9pdb321_002Eil_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003FILViewer_003Fda232ecc044f4c3d8e856366253516531d2800_003F71_003F8a186d8b_003F020002A9pdb321_002Eil/@EntryIndexedValue">ForceIncluded</s:String> + <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003A020002ACpdb869_002Eil_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003FILViewer_003Fda232ecc044f4c3d8e856366253516531d2800_003F00_003F5a1370d8_003F020002ACpdb869_002Eil/@EntryIndexedValue">ForceIncluded</s:String> + <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAssetLoader_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F6dcc875f2facef5a505e1840bcae49509f5b796e47105cc3205aa92843f4753e_003FAssetLoader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AContentControl_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa0b45743773945a3bb67ca6440ae9eadf9c00_003F50_003F9d315227_003FContentControl_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADockFluentTheme_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc13735b26c914624b4ee4a88a575ae253ae00_003Feb_003F23efc6b0_003FDockFluentTheme_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFactory_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe8b9e6b427dceb6f436414441b760d4dc52661df17f386ce4caa48aab354989_003FFactory_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHtmlControl_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F58931fa041a846b53462c4c4c5f52620bf9de09eff582aa4b1ed83c83e4e10ea_003FHtmlControl_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> + <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIAssetLoader_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fda232ecc044f4c3d8e856366253516531d2800_003F_005F27262_003FIAssetLoader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIFactory_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F52dbc4b2fb874f79fb4fec0b07cf7f6ca6ac95616e1d164ef210a0645a1aa9_003FIFactory_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANetworkInformation_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5b1b048ea0e94b28ad7cbac8ef6bc4c26e00_003Fb4_003Fff405095_003FNetworkInformation_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AProportionalDock_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F91c655b1795150937d9264ac1431c463ed5e5e8ad0286ad17e16f16175d94_003FProportionalDock_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> diff --git a/Blacklight/App.axaml.cs b/Blacklight/App.axaml.cs index aa5af35c43e7cdab672fcc766b586b8e795d6cd4..0f9ba21a945e33d702532c64d71fbc3533297e9e 100644 --- a/Blacklight/App.axaml.cs +++ b/Blacklight/App.axaml.cs @@ -47,6 +47,7 @@ public partial class App : Application var path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "blacklight", "login.json"); try { + Console.WriteLine("Deleting login.json"); File.Delete(path); } catch (Exception ex) diff --git a/Blacklight/Assets/dead.png b/Blacklight/Assets/dead.png new file mode 100644 index 0000000000000000000000000000000000000000..19e04b037576294cc953a9cf6cde12343ff22a1f Binary files /dev/null and b/Blacklight/Assets/dead.png differ diff --git a/Blacklight/ViewModels/LoginViewModel.cs b/Blacklight/ViewModels/LoginViewModel.cs index 5c3c558568816152d0046aaa32578349a61618f8..203c6f3a309c77b7ce4914f1161cfc5861f67ce8 100644 --- a/Blacklight/ViewModels/LoginViewModel.cs +++ b/Blacklight/ViewModels/LoginViewModel.cs @@ -2,6 +2,8 @@ using System.IO; using System.Threading; using System.Windows.Input; +using Avalonia.Media.Imaging; +using Avalonia.Platform; using Avalonia.Threading; using Blacklight.Util; using Blacklight.Views.Login; @@ -31,6 +33,7 @@ public class LoginViewModel : ViewModelBase private string _password = string.Empty; private string? _loginError; private string _loadingText = "Loading..."; + private bool _loadingError; public string Email { @@ -56,6 +59,12 @@ public class LoginViewModel : ViewModelBase set => SetProperty(ref _networkError, value); } + public bool LoadingError + { + get => _loadingError; + set => SetProperty(ref _loadingError, value); + } + public string? LoginError { get => _loginError; @@ -96,6 +105,7 @@ public class LoginViewModel : ViewModelBase var network = await Client.GetNetworkAsync(new Uri(persistentData.NetworkBase)); if (network.success) { + Client.UseToken(null, "temp"); Client.NetworkInformation = network.networkInformation; Client.UseToken(persistentData.AccessToken, persistentData.RefreshToken); Console.WriteLine("Found token, showing ClientView"); @@ -104,7 +114,8 @@ public class LoginViewModel : ViewModelBase } else { - LoadingText = $"Failed to connect to network :< ({network.error})"; + LoadingText = $"{network.error}"; + LoadingError = true; } } @@ -132,7 +143,26 @@ public class LoginViewModel : ViewModelBase set => SetProperty(ref _loadingText, value); } + public ICommand ErrorResetCommand => new RelayCommand(ErrorReset); + + private void ErrorReset() + { + Client.LogOut(); + Client.RunLogOut(); + var path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "blacklight", "login.json"); + try + { + Console.WriteLine("Deleting login.json"); + File.Delete(path); + } + catch (Exception ex) + { + Console.Error.WriteLine(ex); + } + UseSolstice(); + } + private async void Login() { LoginError = string.Empty; diff --git a/Blacklight/Views/Login/Loading.axaml b/Blacklight/Views/Login/Loading.axaml index 3f36c7a88333c1bbd9fd25c45c9d0f96808757e1..b537e692a72b5f83c5f85bcd22282a518ddac75a 100644 --- a/Blacklight/Views/Login/Loading.axaml +++ b/Blacklight/Views/Login/Loading.axaml @@ -8,7 +8,7 @@ x:Class="Blacklight.Views.Login.Loading" x:DataType="viewModels:LoginViewModel"> <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <gif:GifImage HorizontalAlignment="Center" VerticalAlignment="Center" Source="avares://Blacklight/Assets/loading.gif" > + <gif:GifImage IsVisible="{Binding !LoadingError}" HorizontalAlignment="Center" VerticalAlignment="Center" Source="avares://Blacklight/Assets/loading.gif"> <gif:GifImage.Effect> <DropShadowEffect Color="#FFFFFF" BlurRadius="50" @@ -16,6 +16,16 @@ Opacity="0.5"/> </gif:GifImage.Effect> </gif:GifImage> - <TextBlock HorizontalAlignment="Center" Text="{Binding LoadingText, FallbackValue='Loading...'}" /> + <Image IsVisible="{Binding LoadingError}" MaxHeight="219" HorizontalAlignment="Center" VerticalAlignment="Center" Source="avares://Blacklight/Assets/dead.png"> + <Image.Effect> + <DropShadowEffect Color="#FFFFFF" + BlurRadius="50" + OffsetX="0" OffsetY="0" + Opacity="0.5"/> + </Image.Effect> + </Image> + + <TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" Text="{Binding LoadingText, FallbackValue='Loading...'}" /> + <Button HorizontalAlignment="Center" IsVisible="{Binding LoadingError}" Command="{Binding ErrorResetCommand}">Log out</Button> </StackPanel> </UserControl> diff --git a/Blacklight/Views/MainWindow.axaml b/Blacklight/Views/MainWindow.axaml index 93cddb0bbee85011b47940735df30d6dd25e4fb3..41e4f7383dbc6247444eb1577738fcaff543ee76 100644 --- a/Blacklight/Views/MainWindow.axaml +++ b/Blacklight/Views/MainWindow.axaml @@ -26,14 +26,14 @@ <ResourceDictionary> <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Light"> - <SolidColorBrush x:Key="RightBeltColor">#F2e9e9e9</SolidColorBrush> - <SolidColorBrush x:Key="NavBarColor">#F2D4DCE2</SolidColorBrush> + <SolidColorBrush x:Key="RightBeltColor">#E2e9e9e9</SolidColorBrush> + <SolidColorBrush x:Key="NavBarColor">#E2D4DCE2</SolidColorBrush> <SolidColorBrush x:Key="NavBarBorderColor">#e1e0dd</SolidColorBrush> - <SolidColorBrush x:Key="ResourceExplorerColor">#F2e9e9e9</SolidColorBrush> + <SolidColorBrush x:Key="ResourceExplorerColor">#E2e9e9e9</SolidColorBrush> <SolidColorBrush x:Key="ResourceExplorerBorderColor">#e1e0dd</SolidColorBrush> <SolidColorBrush x:Key="BottomBarColor">#e9e9e9</SolidColorBrush> - <SolidColorBrush x:Key="DocumentColor">#E6e9e9e9</SolidColorBrush> - <SolidColorBrush x:Key="TabStripColor">#F2e9e9e9</SolidColorBrush> + <SolidColorBrush x:Key="DocumentColor">#D6e9e9e9</SolidColorBrush> + <SolidColorBrush x:Key="TabStripColor">#E2e9e9e9</SolidColorBrush> <SolidColorBrush x:Key="TabPointerOverColor">#1E00FF00</SolidColorBrush> <SolidColorBrush x:Key="DockApplicationAccentBrushLow">Transparent</SolidColorBrush> <SolidColorBrush x:Key="DockApplicationAccentBrushMed">Transparent</SolidColorBrush> diff --git a/Lightquark.NET/Client.cs b/Lightquark.NET/Client.cs index 28731d306fa971841f78f101a1ae37768e6f9b3e..19ddf4fd0a22d5e2c414366e3d4203ae53eb2839 100644 --- a/Lightquark.NET/Client.cs +++ b/Lightquark.NET/Client.cs @@ -78,11 +78,12 @@ public partial class Client : ObservableObject } } } - - if (e.PropertyName == "RefreshToken" && RefreshToken == null && OnLogOut != null) + Console.WriteLine($"Detected {e.PropertyName} change"); + + if (e.PropertyName == "RefreshToken" && RefreshToken == null) { - OnLogOut.Invoke(); - _refreshTimer?.Dispose(); + Console.WriteLine("Detected LogOut"); + RunLogOut(); } base.OnPropertyChanged(e); } diff --git a/Lightquark.NET/ClientMethods/Login.cs b/Lightquark.NET/ClientMethods/Login.cs index 9b77f8ef6a14475bde3d64a18ca70601bb56fb48..d0be610c2b5ea2bc23b227fde097a3011a38ca0b 100644 --- a/Lightquark.NET/ClientMethods/Login.cs +++ b/Lightquark.NET/ClientMethods/Login.cs @@ -46,7 +46,7 @@ public partial class Client } } - public async void UseToken(string accessToken, string refreshToken) + public void UseToken(string? accessToken, string refreshToken) { RefreshToken = refreshToken; AccessToken = accessToken; @@ -96,4 +96,11 @@ public partial class Client AccessToken = null; RefreshToken = null; } + + public void RunLogOut() + { + Console.WriteLine("Logging out!"); + OnLogOut?.Invoke(); + _refreshTimer?.Dispose(); + } } \ No newline at end of file