From 1beca653b772cf10586c417b2c25df03a67df8a2 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 17 Jul 2023 00:21:24 +0200 Subject: Handle external logouts --- MatrixRoomUtils.Web/Shared/InlineUserItem.razor | 9 +++++---- MatrixRoomUtils.Web/Shared/ModalWindow.razor | 22 +++++++++++++++++----- MatrixRoomUtils.Web/Shared/ModalWindow.razor.css | 4 ++-- MatrixRoomUtils.Web/Shared/RoomList.razor | 15 +++++++++------ .../Shared/SimpleComponents/LinkButton.razor | 14 +++++++++----- 5 files changed, 42 insertions(+), 22 deletions(-) (limited to 'MatrixRoomUtils.Web/Shared') diff --git a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor index ffccc25..f9cef91 100644 --- a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor +++ b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor @@ -35,14 +35,15 @@ protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); - var hs = await MRUStorage.GetCurrentSession(); - + var hs = await MRUStorage.GetCurrentSessionOrNavigate(); + if(hs is null) return; + await _semaphoreSlim.WaitAsync(); if (User == null && UserId == null) throw new ArgumentNullException(nameof(UserId)); User ??= await hs.GetProfile(UserId); - + ProfileAvatar ??= MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, User.AvatarUrl); ProfileName ??= User.DisplayName; @@ -50,4 +51,4 @@ _semaphoreSlim.Release(); } -} \ No newline at end of file +} diff --git a/MatrixRoomUtils.Web/Shared/ModalWindow.razor b/MatrixRoomUtils.Web/Shared/ModalWindow.razor index 216f1f3..b40d246 100644 --- a/MatrixRoomUtils.Web/Shared/ModalWindow.razor +++ b/MatrixRoomUtils.Web/Shared/ModalWindow.razor @@ -1,12 +1,12 @@
- @Title + @Title
-
- @ChildContent -
+
+ @ChildContent +
@code { @@ -23,18 +23,30 @@ [Parameter] public double Y { get; set; } = 60; + [Parameter] + public double MinWidth { get; set; } = 100; + [Parameter] public Action OnCloseClicked { get; set; } [Parameter] public bool Collapsed { get; set; } = false; + private ElementReference _titleRef; + private double _x = 60; private double _y = 60; - protected override void OnInitialized() { + protected override async Task OnInitializedAsync() { _x = X; _y = Y; + await base.OnInitializedAsync(); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) { + //set minwidth to title width + MinWidth = await JSRuntime.InvokeAsync("getWidth", _titleRef) + 75; + await base.OnAfterRenderAsync(firstRender); } private void WindowDrag(DragEventArgs obj) { diff --git a/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css b/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css index b25ab0e..6d08114 100644 --- a/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css +++ b/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css @@ -24,6 +24,7 @@ top: 0; left: 0; width: fit-content; + text-wrap: nowrap; height: 100%; line-height: 25px; padding-left: 10px; @@ -55,14 +56,13 @@ cursor: pointer; } -.r-modal > .content { +.r-modal > .r-modal-content { position: relative; top: 25px; left: 0; width: fit-content; height: fit-content; min-width: 150px; - min-height: 5px; max-width: 75vw; max-height: 75vh; overflow: auto; diff --git a/MatrixRoomUtils.Web/Shared/RoomList.razor b/MatrixRoomUtils.Web/Shared/RoomList.razor index fadec1c..e3894a6 100644 --- a/MatrixRoomUtils.Web/Shared/RoomList.razor +++ b/MatrixRoomUtils.Web/Shared/RoomList.razor @@ -22,9 +22,12 @@ else { public ProfileResponseEventData? GlobalProfile { get; set; } Dictionary> RoomsWithTypes = new(); - + protected override async Task OnInitializedAsync() { - GlobalProfile ??= await (await MRUStorage.GetCurrentSession())!.GetProfile((await MRUStorage.GetCurrentSession())!.WhoAmI.UserId); + var hs = await MRUStorage.GetCurrentSessionOrNavigate(); + if (hs is null) return; + + GlobalProfile ??= await hs.GetProfile(hs.WhoAmI.UserId); if (RoomsWithTypes.Any()) return; var tasks = Rooms.Select(ProcessRoom); @@ -41,7 +44,7 @@ else { _ => roomType }; - + private static SemaphoreSlim _semaphoreSlim = new(8, 8); private async Task ProcessRoom(RoomInfo room) { await _semaphoreSlim.WaitAsync(); @@ -59,14 +62,14 @@ else { catch (MatrixException e) { roomType = $"Error: {e.ErrorCode}"; } - + if (!RoomsWithTypes.ContainsKey(roomType)) { RoomsWithTypes.Add(roomType, new List()); } RoomsWithTypes[roomType].Add(room); - + StateHasChanged(); _semaphoreSlim.Release(); } -} \ No newline at end of file +} diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/LinkButton.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/LinkButton.razor index 09b5c32..b800989 100644 --- a/MatrixRoomUtils.Web/Shared/SimpleComponents/LinkButton.razor +++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/LinkButton.razor @@ -1,16 +1,20 @@ - + @ChildContent @code { - + [Parameter] - public string href { get; set; } - + public string? href { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } [Parameter] public string? Color { get; set; } -} \ No newline at end of file + [Parameter] + public Func? OnClick { get; set; } + +} -- cgit 1.5.1