From ec1752307a4a273324cd8f13bb099fed6ff7ef3a Mon Sep 17 00:00:00 2001 From: "Emma@Rory&" Date: Tue, 19 Sep 2023 00:17:18 +0200 Subject: Refactors --- MatrixRoomUtils.Desktop/App.axaml.cs | 4 ++-- MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'MatrixRoomUtils.Desktop') diff --git a/MatrixRoomUtils.Desktop/App.axaml.cs b/MatrixRoomUtils.Desktop/App.axaml.cs index 33f2c13..3963be6 100644 --- a/MatrixRoomUtils.Desktop/App.axaml.cs +++ b/MatrixRoomUtils.Desktop/App.axaml.cs @@ -20,8 +20,8 @@ public partial class App : Application { services.AddSingleton(); services.AddSingleton(x => new TieredStorageService( - cacheStorageProvider: new FileStorageProvider(x.GetService().CacheStoragePath), - dataStorageProvider: new FileStorageProvider(x.GetService().DataStoragePath) + cacheStorageProvider: new FileStorageProvider(x.GetService()!.CacheStoragePath), + dataStorageProvider: new FileStorageProvider(x.GetService()!.DataStoragePath) ) ); services.AddSingleton(new RoryLibMatrixConfiguration { diff --git a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs index 6cdb767..d687679 100644 --- a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs +++ b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs @@ -2,9 +2,10 @@ using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Media.Imaging; using LibMatrix; +using LibMatrix.EventTypes.Spec.State; using LibMatrix.Helpers; +using LibMatrix.Interfaces.Services; using LibMatrix.Services; -using LibMatrix.StateEventTypes.Spec; using Microsoft.Extensions.DependencyInjection; namespace MatrixRoomUtils.Desktop.Components; @@ -43,9 +44,10 @@ public partial class RoomListEntry : UserControl { if (avatarEvent?.TypedContent is RoomAvatarEventContent avatarData) { var mxcUrl = avatarData.Url; await using var svc = _serviceScopeFactory.CreateAsyncScope(); - var hs = await svc.ServiceProvider.GetService().GetCurrentSessionOrPrompt(); - var storage = svc.ServiceProvider.GetService().CacheStorageProvider; - var resolvedUrl = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, mxcUrl); + var hs = await svc.ServiceProvider.GetService()?.GetCurrentSessionOrPrompt()!; + var hsResolver = svc.ServiceProvider.GetService(); + var storage = svc.ServiceProvider.GetService()?.CacheStorageProvider; + var resolvedUrl = await hsResolver.ResolveMediaUri(hs.FullHomeServerDomain, mxcUrl); var storageKey = $"media/{mxcUrl.Replace("mxc://", "").Replace("/", ".")}"; try { if (!await storage.ObjectExistsAsync(storageKey)) -- cgit 1.5.1