From 1cccdcb832f59431e8432a412c85cc6b4db88eee Mon Sep 17 00:00:00 2001 From: Jeder Date: Wed, 6 Nov 2024 21:40:48 +0100 Subject: [PATCH] [frontend/components] Refactor notifications --- .../Components/NotificationComponent.razor | 131 ++++++++---------- .../NotificationComponent.razor.css | 3 +- 2 files changed, 61 insertions(+), 73 deletions(-) diff --git a/Iceshrimp.Frontend/Components/NotificationComponent.razor b/Iceshrimp.Frontend/Components/NotificationComponent.razor index ff59cd10..7a8eef40 100644 --- a/Iceshrimp.Frontend/Components/NotificationComponent.razor +++ b/Iceshrimp.Frontend/Components/NotificationComponent.razor @@ -7,86 +7,73 @@ @inject NavigationManager NavigationManager
-
- @if (NotificationResponse is { User: not null }) - { - - } - -
+ @if (NotificationResponse is not { Type: "mention" } or { Type: "reply" }) + { +
@if (NotificationResponse is { User: not null }) { - + } - @if (NotificationResponse is { Note: not null, Type: "like", User: not null }) - { - @Loc["liked your post: "] - } - else if (NotificationResponse is { Note: not null, Type: "reaction" }) - { - @Loc["reacted to your post:"] - } - else if (NotificationResponse is { Type: "follow", User: not null }) - { - @Loc["followed you"] - } - else if (NotificationResponse is { Type: "followRequestReceived" }) - { - @Loc["requested to follow you"] - } - else if (NotificationResponse is { Type: "followRequestAccepted" }) - { - @Loc["accepted your follow request"] - } - else if (NotificationResponse is { Type: "mention" }) - { - @Loc["mentioned you:"] - } - else if (NotificationResponse is { Type: "reply" }) - { - @Loc["replied to your post:"] - } - else if (NotificationResponse is { Type: "renote" }) - { - @Loc["renoted your post:"] - } - else if (NotificationResponse is { Type: "quote" }) - { - @Loc["quoted your post:"] - } - else if (NotificationResponse is { Bite: { BiteBack: true }, Type: "bite" }) - { - @Loc["bit you back"] - } - else if (NotificationResponse is { Note: not null, Type: "bite" }) - { - @Loc["bit your note:"] - } - else if (NotificationResponse is { Type: "bite" }) - { - @Loc["bit you"] - } - else - { - - @Loc["unsupported notification type"] - -
- view details -

ID: @NotificationResponse.Id

-

Type: @NotificationResponse.Type

-
- } -
+
+ @if (NotificationResponse is { User: not null }) + { + @(NotificationResponse.User.DisplayName ?? NotificationResponse.User.Username) + } + + @switch (NotificationResponse) + { + case { Note: not null, Type: "like", User: not null }: + @Loc["liked your note"] + break; + case { Note: not null, Type: "reaction" }: + @Loc["reacted to your note"] + break; + case { Type: "follow", User: not null }: + @Loc["followed you"] + break; + case { Type: "followRequestReceived" }: + @Loc["requested to follow you"] + break; + case { Type: "followRequestAccepted" }: + @Loc["accepted your follow request"] + break; + case { Type: "renote" }: + @Loc["renoted your note"] + break; + case { Type: "quote" }: + @Loc["quoted your note"] + break; + case { Bite: { BiteBack: true }, Type: "bite" }: + @Loc["bit you back"] + break; + case { Note: not null, Type: "bite" }: + @Loc["bit your note"] + break; + case { Type: "bite" }: + @Loc["bit you"] + break; + default: + + @Loc["unsupported notification type"] + +
+ view details +

ID: @NotificationResponse.Id

+

Type: @NotificationResponse.Type

+
+ break; + } +
- @RenderDate(DateTime.Parse(NotificationResponse.CreatedAt)) -
+ @RenderDate(DateTime.Parse(NotificationResponse.CreatedAt)) +
+ } @if (NotificationResponse is { Note: not null }) { -
- +
+
}
diff --git a/Iceshrimp.Frontend/Components/NotificationComponent.razor.css b/Iceshrimp.Frontend/Components/NotificationComponent.razor.css index 240fbdc2..a8e3a2b0 100644 --- a/Iceshrimp.Frontend/Components/NotificationComponent.razor.css +++ b/Iceshrimp.Frontend/Components/NotificationComponent.razor.css @@ -10,6 +10,7 @@ } .notification-text { + font-size: 0.8em; } .notification-note { @@ -29,7 +30,7 @@ object-fit: cover; width: 3em; height: 3em; - margin-right: 0.5em; + margin-right: 0.75em; } .display-name {