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/Components/RoomListEntry.axaml.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'MatrixRoomUtils.Desktop/Components') 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