From f639da67e2d942df485ce457f0eff064d4082506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Pilgaard=20Gr=C3=B8ndahl?= Date: Sun, 18 Aug 2024 22:55:41 +0200 Subject: [PATCH] less null refs --- .../Features/Chat/ChatMessageList.razor | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/web/Jordnaer/Features/Chat/ChatMessageList.razor b/src/web/Jordnaer/Features/Chat/ChatMessageList.razor index b3d502be..bab51b1a 100644 --- a/src/web/Jordnaer/Features/Chat/ChatMessageList.razor +++ b/src/web/Jordnaer/Features/Chat/ChatMessageList.razor @@ -11,29 +11,30 @@ - @if (ActiveChat is null && IsMobile is false) + @switch (ActiveChat) { - - - Vælg én at skrive med - - return; + case null when IsMobile: + return; + case null when IsMobile is false: + + + Vælg én at skrive med + + return; + case not null when IsMobile: + + + @ActiveChat.GetDisplayName(CurrentUser.Id!) + + break; } - @if (IsMobile) - { - - - @ActiveChat.GetDisplayName(CurrentUser.Id!) - - } - @*The elements below cannot be readonly/disabled, as it disabled the tooltips *@ @@ -163,7 +164,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { - await JsRuntime.ScrollToBottomOfElement(".chat-message-window"); + await JsRuntime.ScrollToBottomOfElement(".chat-message-window"); } private void MarkMessageIfSuccessfullySentByCurrentUser()