diff options
Diffstat (limited to 'MatrixRoomUtils.Desktop')
-rw-r--r-- | MatrixRoomUtils.Desktop/App.axaml.cs | 12 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/Components/NavigationStack.axaml | 12 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs | 24 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml | 21 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs | 15 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml | 9 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs | 31 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/FileStorageProvider.cs | 49 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/LoginWindow.axaml | 18 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/LoginWindow.axaml.cs | 1 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/MRUStorageWrapper.cs | 6 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/MainWindow.axaml.cs | 13 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj | 29 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/Properties/launchSettings.json | 3 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/RoomInfo.cs | 40 | ||||
-rw-r--r-- | MatrixRoomUtils.Desktop/SentryService.cs | 2 |
16 files changed, 140 insertions, 145 deletions
diff --git a/MatrixRoomUtils.Desktop/App.axaml.cs b/MatrixRoomUtils.Desktop/App.axaml.cs index 3963be6..aeb154c 100644 --- a/MatrixRoomUtils.Desktop/App.axaml.cs +++ b/MatrixRoomUtils.Desktop/App.axaml.cs @@ -1,7 +1,9 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using Avalonia.Styling; using LibMatrix.Services; +using MatrixRoomUtils.Abstractions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -10,10 +12,6 @@ namespace MatrixRoomUtils.Desktop; public partial class App : Application { public IHost host { get; set; } - public override void Initialize() { - AvaloniaXamlLoader.Load(this); - } - public override void OnFrameworkInitializationCompleted() { host = Host.CreateDefaultBuilder().ConfigureServices((ctx, services) => { services.AddSingleton<MRUDesktopConfiguration>(); @@ -42,6 +40,10 @@ public partial class App : Application { var scope = scopeFac.CreateScope(); desktop.MainWindow = scope.ServiceProvider.GetRequiredService<MainWindow>(); } + + if(Environment.GetEnvironmentVariable("AVALONIA_THEME")?.Equals("dark", StringComparison.OrdinalIgnoreCase) ?? false) + RequestedThemeVariant = ThemeVariant.Dark; + base.OnFrameworkInitializationCompleted(); } -} +} \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml index c773b8d..bc6b75d 100644 --- a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml +++ b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml @@ -4,9 +4,9 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="MatrixRoomUtils.Desktop.Components.NavigationStack"> - <DockPanel x:Name="dock"> - <StackPanel x:Name="navPanel"></StackPanel> - <UserControl x:Name="content"></UserControl> - </DockPanel> - -</UserControl> + <StackPanel x:Name="dock"> + <Label>NagivationStack</Label> + <StackPanel x:Name="navPanel" Orientation="Horizontal"></StackPanel> + <ContentControl x:Name="content"></ContentControl> + </StackPanel> +</UserControl> \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs index d6343e2..92c617b 100644 --- a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs +++ b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs @@ -1,4 +1,5 @@ using Avalonia.Controls; +using Avalonia.Interactivity; using Avalonia.Markup.Xaml; namespace MatrixRoomUtils.Desktop.Components; @@ -8,12 +9,24 @@ public partial class NavigationStack : UserControl { InitializeComponent(); } - private void InitializeComponent() { - AvaloniaXamlLoader.Load(this); + // private void InitializeComponent() { + // AvaloniaXamlLoader.Load(this); + // buildView(); + // } + + protected override void OnLoaded(RoutedEventArgs e) { + base.OnLoaded(e); buildView(); } - + private void buildView() { + if (navPanel is null) { + Console.WriteLine("NavigationStack buildView called while navpanel is null!"); + // await Task.Delay(100); + // if (navPanel is null) + // await buildView(); + // else Console.WriteLine("navpanel is not null!"); + } navPanel.Children.Clear(); foreach (var item in _stack) { Button btn = new() { @@ -25,7 +38,7 @@ public partial class NavigationStack : UserControl { }; navPanel.Children.Add(btn); } - content = Current?.View ?? new UserControl(); + content.Content = Current?.View ?? new UserControl(); } @@ -44,13 +57,16 @@ public partial class NavigationStack : UserControl { Name = name, View = view }); + buildView(); } public void Pop() { _stack.RemoveAt(_stack.Count - 1); + buildView(); } public void PopTo(int index) { _stack.RemoveRange(index, _stack.Count - index); + buildView(); } } diff --git a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml b/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml new file mode 100644 index 0000000..0e43d99 --- /dev/null +++ b/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml @@ -0,0 +1,21 @@ +<UserControl xmlns="https://github.com/avaloniaui" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:components="clr-namespace:MatrixRoomUtils.Desktop.Components.Pages" + xmlns:components1="clr-namespace:MatrixRoomUtils.Desktop.Components" + xmlns:abstractions="clr-namespace:MatrixRoomUtils.Abstractions;assembly=MatrixRoomUtils.Abstractions" + + mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + x:Class="MatrixRoomUtils.Desktop.Components.Pages.RoomList" + x:DataType="components:RoomList" + DataContext="{Binding $self}" + > + <ListBox ItemsSource="{Binding Rooms}"> + <ListBox.ItemTemplate> + <DataTemplate DataType="abstractions:RoomInfo"> + <components1:RoomListEntry Room="{Binding Path=.}"/> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> +</UserControl> diff --git a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs b/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs new file mode 100644 index 0000000..53c3063 --- /dev/null +++ b/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs @@ -0,0 +1,15 @@ +using System.Collections.ObjectModel; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using MatrixRoomUtils.Abstractions; + +namespace MatrixRoomUtils.Desktop.Components.Pages; + +public partial class RoomList : UserControl { + private ObservableCollection<RoomInfo> Rooms { get; set; } = new(); + + public RoomList() { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml index 09fe52b..db22ccc 100644 --- a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml +++ b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml @@ -2,10 +2,15 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:components="clr-namespace:MatrixRoomUtils.Desktop.Components" mc:Ignorable="d" d:DesignWidth="250" d:DesignHeight="32" - x:Class="MatrixRoomUtils.Desktop.Components.RoomListEntry"> + x:Class="MatrixRoomUtils.Desktop.Components.RoomListEntry" + + x:DataType="components:RoomListEntry" + DataContext="{Binding $self}" + > <StackPanel Orientation="Horizontal"> <Image MaxWidth="64" x:Name="RoomIcon"></Image> - <Label x:Name="RoomName"></Label> + <Label x:Name="RoomName" Content="{Binding Room.RoomName}"></Label> </StackPanel> </UserControl> diff --git a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs index 69458aa..73115a2 100644 --- a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs +++ b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs @@ -7,29 +7,28 @@ using LibMatrix.EventTypes.Spec.State.RoomInfo; using LibMatrix.Helpers; using LibMatrix.Interfaces.Services; using LibMatrix.Services; +using MatrixRoomUtils.Abstractions; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; namespace MatrixRoomUtils.Desktop.Components; public partial class RoomListEntry : UserControl { - private readonly IServiceScopeFactory _serviceScopeFactory; - private readonly RoomInfo _roomInfo; + public RoomInfo Room { get; set; } - public RoomListEntry(IServiceScopeFactory serviceScopeFactory, RoomInfo roomInfo) { - _serviceScopeFactory = serviceScopeFactory; - _roomInfo = roomInfo; + public RoomListEntry() { InitializeComponent(); } protected override void OnLoaded(RoutedEventArgs e) { base.OnLoaded(e); - RoomName.Content = _roomInfo.Room.RoomId; + RoomName.Content = Room.Room.RoomId; Task.WhenAll(GetRoomName(), GetRoomIcon()); } private async Task GetRoomName() { try { - var nameEvent = await _roomInfo.GetStateEvent("m.room.name"); + var nameEvent = await Room.GetStateEvent("m.room.name"); if (nameEvent?.TypedContent is RoomNameEventContent nameData) RoomName.Content = nameData.Name; } @@ -41,18 +40,22 @@ public partial class RoomListEntry : UserControl { private async Task GetRoomIcon() { try { - var avatarEvent = await _roomInfo.GetStateEvent("m.room.avatar"); + using var hc = new HttpClient(); + var avatarEvent = await Room.GetStateEvent("m.room.avatar"); if (avatarEvent?.TypedContent is RoomAvatarEventContent avatarData) { var mxcUrl = avatarData.Url; - await using var svc = _serviceScopeFactory.CreateAsyncScope(); - var hs = await svc.ServiceProvider.GetService<MRUStorageWrapper>()?.GetCurrentSessionOrPrompt()!; - var hsResolver = svc.ServiceProvider.GetService<HomeserverResolverService>(); - var storage = svc.ServiceProvider.GetService<TieredStorageService>()?.CacheStorageProvider; - var resolvedUrl = await hsResolver.ResolveMediaUri(hs.ServerName, mxcUrl); + var resolvedUrl = await Room.Room.GetResolvedRoomAvatarUrlAsync(); + + // await using var svc = _serviceScopeFactory.CreateAsyncScope(); + // var hs = await svc.ServiceProvider.GetService<MRUStorageWrapper>()?.GetCurrentSessionOrPrompt()!; + // var hsResolver = svc.ServiceProvider.GetService<HomeserverResolverService>(); + // var storage = svc.ServiceProvider.GetService<TieredStorageService>()?.CacheStorageProvider; + // var resolvedUrl = await hsResolver.ResolveMediaUri(hs.ServerName, mxcUrl); + var storage = new FileStorageProvider("cache"); var storageKey = $"media/{mxcUrl.Replace("mxc://", "").Replace("/", ".")}"; try { if (!await storage.ObjectExistsAsync(storageKey)) - await storage.SaveStreamAsync(storageKey, await hs.ClientHttpClient.GetStreamAsync(resolvedUrl)); + await storage.SaveStreamAsync(storageKey, await hc.GetStreamAsync(resolvedUrl)); RoomIcon.Source = new Bitmap(await storage.LoadStreamAsync(storageKey) ?? throw new NullReferenceException()); } diff --git a/MatrixRoomUtils.Desktop/FileStorageProvider.cs b/MatrixRoomUtils.Desktop/FileStorageProvider.cs deleted file mode 100644 index 0429d1a..0000000 --- a/MatrixRoomUtils.Desktop/FileStorageProvider.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using ArcaneLibs.Extensions; -using LibMatrix.Extensions; -using LibMatrix.Interfaces.Services; -using Microsoft.Extensions.Logging; - -namespace MatrixRoomUtils.Desktop; - -public class FileStorageProvider : IStorageProvider { - private readonly ILogger<FileStorageProvider> _logger; - - public string TargetPath { get; } - - /// <summary> - /// Creates a new instance of <see cref="FileStorageProvider" />. - /// </summary> - /// <param name="targetPath"></param> - public FileStorageProvider(string targetPath) { - new Logger<FileStorageProvider>(new LoggerFactory()).LogInformation("test"); - Console.WriteLine($"Initialised FileStorageProvider with path {targetPath}"); - TargetPath = targetPath; - if (!Directory.Exists(targetPath)) { - Directory.CreateDirectory(targetPath); - } - } - - public async Task SaveObjectAsync<T>(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), value?.ToJson()); - - [RequiresUnreferencedCode("This API uses reflection to deserialize JSON")] - public async Task<T?> LoadObjectAsync<T>(string key) => JsonSerializer.Deserialize<T>(await File.ReadAllTextAsync(Path.Join(TargetPath, key))); - - public Task<bool> ObjectExistsAsync(string key) => Task.FromResult(File.Exists(Path.Join(TargetPath, key))); - - public Task<List<string>> GetAllKeysAsync() => Task.FromResult(Directory.GetFiles(TargetPath).Select(Path.GetFileName).ToList()); - - public Task DeleteObjectAsync(string key) { - File.Delete(Path.Join(TargetPath, key)); - return Task.CompletedTask; - } - - public async Task SaveStreamAsync(string key, Stream stream) { - Directory.CreateDirectory(Path.GetDirectoryName(Path.Join(TargetPath, key)) ?? throw new InvalidOperationException()); - await using var fileStream = File.Create(Path.Join(TargetPath, key)); - await stream.CopyToAsync(fileStream); - } - - public Task<Stream?> LoadStreamAsync(string key) => Task.FromResult<Stream?>(File.Exists(Path.Join(TargetPath, key)) ? File.OpenRead(Path.Join(TargetPath, key)) : null); -} diff --git a/MatrixRoomUtils.Desktop/LoginWindow.axaml b/MatrixRoomUtils.Desktop/LoginWindow.axaml index a4600d5..fc0ee6f 100644 --- a/MatrixRoomUtils.Desktop/LoginWindow.axaml +++ b/MatrixRoomUtils.Desktop/LoginWindow.axaml @@ -4,14 +4,22 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:desktop="clr-namespace:MatrixRoomUtils.Desktop" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="MatrixRoomUtils.Desktop.LoginWindow" Title="LoginWindow" + x:Class="MatrixRoomUtils.Desktop.LoginWindow" x:DataType="desktop:LoginWindow" DataContext="{Binding $self}" - > + SizeToContent="WidthAndHeight" CanResize="False" + MinWidth="250"> <StackPanel> - <TextBox Text="{Binding Username, Mode=TwoWay}" /> - <MaskedTextBox PasswordChar="*" Text="{Binding Password, Mode=TwoWay}" /> + <Label>Log in</Label> + <StackPanel Orientation="Horizontal"> + <Label Width="100">User ID</Label> + <TextBox MinWidth="250" Text="{Binding Username, Mode=TwoWay}" /> + </StackPanel> + <StackPanel Orientation="Horizontal"> + <Label Width="100">Password</Label> + <MaskedTextBox MinWidth="250" PasswordChar="*" Text="{Binding Password, Mode=TwoWay}" /> + </StackPanel> <Button Click="Login">Login</Button> </StackPanel> -</Window> +</Window> \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/LoginWindow.axaml.cs b/MatrixRoomUtils.Desktop/LoginWindow.axaml.cs index 1f31b05..183c46b 100644 --- a/MatrixRoomUtils.Desktop/LoginWindow.axaml.cs +++ b/MatrixRoomUtils.Desktop/LoginWindow.axaml.cs @@ -2,6 +2,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Markup.Xaml; +using Avalonia.VisualTree; namespace MatrixRoomUtils.Desktop; diff --git a/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs b/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs index 8a44518..b69c50d 100644 --- a/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs +++ b/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs @@ -1,3 +1,4 @@ +using Avalonia; using LibMatrix; using LibMatrix.Homeservers; using LibMatrix.Responses; @@ -74,8 +75,11 @@ public class MRUStorageWrapper(TieredStorageService storageService, HomeserverPr if (session is null) { // _navigationManager.NavigateTo("/Login"); var wnd = new LoginWindow(this); + wnd.Position = MainWindow.Instance.Position + new PixelPoint(50, 50); await wnd.ShowDialog(MainWindow.Instance); - while (wnd.IsVisible) await Task.Delay(100); + while (wnd.IsVisible) { + await Task.Delay(100); + } session = await GetCurrentSession(); } diff --git a/MatrixRoomUtils.Desktop/MainWindow.axaml.cs b/MatrixRoomUtils.Desktop/MainWindow.axaml.cs index 9db59c5..6ef573e 100644 --- a/MatrixRoomUtils.Desktop/MainWindow.axaml.cs +++ b/MatrixRoomUtils.Desktop/MainWindow.axaml.cs @@ -1,5 +1,7 @@ using Avalonia.Controls; using Avalonia.Interactivity; +using MatrixRoomUtils.Abstractions; +using MatrixRoomUtils.Desktop.Components; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -26,7 +28,6 @@ public partial class MainWindow : Window { _logger.LogInformation("Cache location: {}", _configuration.CacheStoragePath); _logger.LogInformation("Data location: {}", _configuration.DataStoragePath); - // for (int i = 0; i < 100; i++) { // roomList.Children.Add(new RoomListEntry()); // } @@ -39,12 +40,18 @@ public partial class MainWindow : Window { var rooms = await hs.GetJoinedRooms(); foreach (var room in rooms) { // roomList.Children.Add(new RoomListEntry(_scopeFactory, new RoomInfo(room))); + + windowContent.Push("home", new RoomListEntry() { + Room = new RoomInfo() { + Room = room + } + }); + base.OnLoaded(e); } - base.OnLoaded(e); } // public Command // protected void LoadedCommand() { // _logger.LogInformation("async command"); // } -} +} \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj b/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj index 6d9fc0e..94bf245 100644 --- a/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj +++ b/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj @@ -10,29 +10,27 @@ <LangVersion>preview</LangVersion> <ImplicitUsings>enable</ImplicitUsings> <InvariantGlobalization>true</InvariantGlobalization> - <PublishTrimmed>true</PublishTrimmed> - <PublishReadyToRun>true</PublishReadyToRun> - <PublishSingleFile>true</PublishSingleFile> - <PublishReadyToRunShowWarnings>true</PublishReadyToRunShowWarnings> - <PublishTrimmedShowLinkerSizeComparison>true</PublishTrimmedShowLinkerSizeComparison> - <PublishTrimmedShowLinkerSizeComparisonWarnings>true</PublishTrimmedShowLinkerSizeComparisonWarnings> +<!-- <PublishTrimmed>true</PublishTrimmed>--> +<!-- <PublishReadyToRun>true</PublishReadyToRun>--> +<!-- <PublishSingleFile>true</PublishSingleFile>--> +<!-- <PublishReadyToRunShowWarnings>true</PublishReadyToRunShowWarnings>--> +<!-- <PublishTrimmedShowLinkerSizeComparison>true</PublishTrimmedShowLinkerSizeComparison>--> +<!-- <PublishTrimmedShowLinkerSizeComparisonWarnings>true</PublishTrimmedShowLinkerSizeComparisonWarnings>--> </PropertyGroup> <ItemGroup> - <PackageReference Include="Avalonia" Version="11.0.5" /> - <PackageReference Include="Avalonia.Desktop" Version="11.0.5" /> - <PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" /> - <PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.5" /> + <PackageReference Include="Avalonia" Version="11.0.6" /> + <PackageReference Include="Avalonia.Desktop" Version="11.0.6" /> + <PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" /> + <PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.6" /> <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> - <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.5" /> + <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.6" /> <PackageReference Include="Sentry" Version="3.36.0" /> </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\LibMatrix\LibMatrix\LibMatrix.csproj" /> - </ItemGroup> + <ItemGroup> <PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.5" /> @@ -46,4 +44,7 @@ <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\MatrixRoomUtils.Abstractions\MatrixRoomUtils.Abstractions.csproj" /> + </ItemGroup> </Project> diff --git a/MatrixRoomUtils.Desktop/Properties/launchSettings.json b/MatrixRoomUtils.Desktop/Properties/launchSettings.json index 997e294..36405e8 100644 --- a/MatrixRoomUtils.Desktop/Properties/launchSettings.json +++ b/MatrixRoomUtils.Desktop/Properties/launchSettings.json @@ -12,7 +12,8 @@ "commandName": "Project", "dotnetRunMessages": true, "environmentVariables": { - "DOTNET_ENVIRONMENT": "Development" + "DOTNET_ENVIRONMENT": "Development", + "AVALONIA_THEME": "Dark" } }, "Local config": { diff --git a/MatrixRoomUtils.Desktop/RoomInfo.cs b/MatrixRoomUtils.Desktop/RoomInfo.cs deleted file mode 100644 index a562086..0000000 --- a/MatrixRoomUtils.Desktop/RoomInfo.cs +++ /dev/null @@ -1,40 +0,0 @@ -using LibMatrix; -using LibMatrix.EventTypes; -using LibMatrix.Interfaces; -using LibMatrix.Responses; -using LibMatrix.RoomTypes; - -namespace MatrixRoomUtils.Desktop; - -public class RoomInfo { - public RoomInfo() { } - - public RoomInfo(GenericRoom room) { - Room = room; - } - - public GenericRoom Room { get; set; } - public List<StateEventResponse?> StateEvents { get; init; } = new(); - - public async Task<StateEventResponse?> GetStateEvent(string type, string stateKey = "") { - var @event = StateEvents.FirstOrDefault(x => x.Type == type && x.StateKey == stateKey); - if (@event is not null) return @event; - @event = new StateEventResponse { - RoomId = Room.RoomId, - Type = type, - StateKey = stateKey, - Sender = null, //TODO: implement - EventId = null - }; - try { - @event.TypedContent = await Room.GetStateAsync<EventContent>(type, stateKey); - } - catch (MatrixException e) { - if (e is { ErrorCode: "M_NOT_FOUND" }) @event.TypedContent = default!; - else throw; - } - - StateEvents.Add(@event); - return @event; - } -} diff --git a/MatrixRoomUtils.Desktop/SentryService.cs b/MatrixRoomUtils.Desktop/SentryService.cs index 648946c..26212fa 100644 --- a/MatrixRoomUtils.Desktop/SentryService.cs +++ b/MatrixRoomUtils.Desktop/SentryService.cs @@ -6,7 +6,7 @@ namespace MatrixRoomUtils.Desktop; public class SentryService : IDisposable { private IDisposable? _sentrySdkDisposable; - public SentryService(IServiceScopeFactory scopeFactory, ILogger logger) { + public SentryService(IServiceScopeFactory scopeFactory, ILogger<SentryService> logger) { var config = scopeFactory.CreateScope().ServiceProvider.GetRequiredService<MRUDesktopConfiguration>(); if (config.SentryDsn is null) { logger.LogWarning("Sentry DSN is not set, skipping Sentry initialisation"); |