diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-07-17 00:21:24 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-07-17 00:21:24 +0200 |
commit | 1beca653b772cf10586c417b2c25df03a67df8a2 (patch) | |
tree | d539b5f329cb62f253e1bc8142c3a313719657b0 /MatrixRoomUtils.Web/Shared | |
parent | Changes (diff) | |
download | MatrixUtils-1beca653b772cf10586c417b2c25df03a67df8a2.tar.xz |
Handle external logouts
Diffstat (limited to 'MatrixRoomUtils.Web/Shared')
-rw-r--r-- | MatrixRoomUtils.Web/Shared/InlineUserItem.razor | 9 | ||||
-rw-r--r-- | MatrixRoomUtils.Web/Shared/ModalWindow.razor | 22 | ||||
-rw-r--r-- | MatrixRoomUtils.Web/Shared/ModalWindow.razor.css | 4 | ||||
-rw-r--r-- | MatrixRoomUtils.Web/Shared/RoomList.razor | 15 | ||||
-rw-r--r-- | MatrixRoomUtils.Web/Shared/SimpleComponents/LinkButton.razor | 14 |
5 files changed, 42 insertions, 22 deletions
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 @@ <div class="r-modal" style="top: @(_y)px; left: @(_x)px;"> <div class="titlebar" @onmousedown="MouseDown" @onmouseup="MouseUp" @onmousemove="MouseMove" @onmouseleave="MouseMove"> - <b class="title">@Title</b> + <b class="title" @ref="_titleRef">@Title</b> <button class="btnclose" @onclick="OnCloseClicked">X</button> <button class="btncollapse" @onclick="@(() => Collapsed = !Collapsed)">_</button> </div> - <div class="content" style="@(Collapsed ? "height: 0px;" : "")"> - @ChildContent - </div> + <div class="r-modal-content" style="@((Collapsed ? "height: 0px;" : "") + $"min-width: {MinWidth}px;")"> + @ChildContent + </div> </div> @code { @@ -24,17 +24,29 @@ 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<int>("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<string, List<RoomInfo>> 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<RoomInfo>()); } 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 @@ -<a href="@href" class="btn btn-primary" style="background-color: @(Color ?? "#1b6ec2");"> +<a href="@href" class="btn btn-primary" @onclick="@(() => OnClick?.Invoke())" + style="background-color: @(Color ?? "#1b6ec2");"> @ChildContent </a> @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<Task>? OnClick { get; set; } + +} |