a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[frontend/components] Refactor notifications

authored by

Jeder and committed by
Iceshrimp development
1cccdcb8 579f8c23

+61 -73
+59 -72
Iceshrimp.Frontend/Components/NotificationComponent.razor
··· 7 7 @inject NavigationManager NavigationManager 8 8 9 9 <div class="notification"> 10 - <div class="notification-header"> 11 - @if (NotificationResponse is { User: not null }) 12 - { 13 - <img @onclick="OpenProfile" class="user-avatar" src="@NotificationResponse.User.AvatarUrl"/> 14 - } 15 - 16 - <div class="notification-body"> 10 + @if (NotificationResponse is not { Type: "mention" } or { Type: "reply" }) 11 + { 12 + <div class="notification-header"> 17 13 @if (NotificationResponse is { User: not null }) 18 14 { 19 - <span @onclick="OpenProfile" class="display-name"><UserDisplayName User="@NotificationResponse.User"/></span> 15 + <img @onclick="OpenProfile" class="user-avatar" src="@NotificationResponse.User.AvatarUrl"/> 20 16 } 21 17 22 - @if (NotificationResponse is { Note: not null, Type: "like", User: not null }) 23 - { 24 - <span class="notification-text">@Loc["liked your post: "]</span> 25 - } 26 - else if (NotificationResponse is { Note: not null, Type: "reaction" }) 27 - { 28 - <span class="notification-text">@Loc["reacted to your post:"]</span> 29 - } 30 - else if (NotificationResponse is { Type: "follow", User: not null }) 31 - { 32 - <span class="notification-text">@Loc["followed you"]</span> 33 - } 34 - else if (NotificationResponse is { Type: "followRequestReceived" }) 35 - { 36 - <span class="notification-text">@Loc["requested to follow you"]</span> 37 - } 38 - else if (NotificationResponse is { Type: "followRequestAccepted" }) 39 - { 40 - <span class="notification-text">@Loc["accepted your follow request"]</span> 41 - } 42 - else if (NotificationResponse is { Type: "mention" }) 43 - { 44 - <span class="notification-text">@Loc["mentioned you:"]</span> 45 - } 46 - else if (NotificationResponse is { Type: "reply" }) 47 - { 48 - <span class="notification-text">@Loc["replied to your post:"]</span> 49 - } 50 - else if (NotificationResponse is { Type: "renote" }) 51 - { 52 - <span class="notification-text">@Loc["renoted your post:"]</span> 53 - } 54 - else if (NotificationResponse is { Type: "quote" }) 55 - { 56 - <span class="notification-text">@Loc["quoted your post:"]</span> 57 - } 58 - else if (NotificationResponse is { Bite: { BiteBack: true }, Type: "bite" }) 59 - { 60 - <span class="notification-text">@Loc["bit you back"]</span> 61 - } 62 - else if (NotificationResponse is { Note: not null, Type: "bite" }) 63 - { 64 - <span class="notification-text">@Loc["bit your note:"]</span> 65 - } 66 - else if (NotificationResponse is { Type: "bite" }) 67 - { 68 - <span class="notification-text">@Loc["bit you"]</span> 69 - } 70 - else 71 - { 72 - <span class="notification-text"> 73 - <i>@Loc["unsupported notification type"]</i> 74 - </span> 75 - <details> 76 - <summary>view details</summary> 77 - <p>ID: @NotificationResponse.Id</p> 78 - <p>Type: @NotificationResponse.Type</p> 79 - </details> 80 - } 18 + <div class="notification-body"> 19 + @if (NotificationResponse is { User: not null }) 20 + { 21 + <span @onclick="OpenProfile" class="display-name">@(NotificationResponse.User.DisplayName ?? NotificationResponse.User.Username)</span> 22 + } 23 + 24 + @switch (NotificationResponse) 25 + { 26 + case { Note: not null, Type: "like", User: not null }: 27 + <span class="notification-text">@Loc["liked your note"]</span> 28 + break; 29 + case { Note: not null, Type: "reaction" }: 30 + <span class="notification-text">@Loc["reacted to your note"]</span> 31 + break; 32 + case { Type: "follow", User: not null }: 33 + <span class="notification-text">@Loc["followed you"]</span> 34 + break; 35 + case { Type: "followRequestReceived" }: 36 + <span class="notification-text">@Loc["requested to follow you"]</span> 37 + break; 38 + case { Type: "followRequestAccepted" }: 39 + <span class="notification-text">@Loc["accepted your follow request"]</span> 40 + break; 41 + case { Type: "renote" }: 42 + <span class="notification-text">@Loc["renoted your note"]</span> 43 + break; 44 + case { Type: "quote" }: 45 + <span class="notification-text">@Loc["quoted your note"]</span> 46 + break; 47 + case { Bite: { BiteBack: true }, Type: "bite" }: 48 + <span class="notification-text">@Loc["bit you back"]</span> 49 + break; 50 + case { Note: not null, Type: "bite" }: 51 + <span class="notification-text">@Loc["bit your note"]</span> 52 + break; 53 + case { Type: "bite" }: 54 + <span class="notification-text">@Loc["bit you"]</span> 55 + break; 56 + default: 57 + <span class="notification-text"> 58 + <i>@Loc["unsupported notification type"]</i> 59 + </span> 60 + <details> 61 + <summary>view details</summary> 62 + <p>ID: @NotificationResponse.Id</p> 63 + <p>Type: @NotificationResponse.Type</p> 64 + </details> 65 + break; 66 + } 67 + </div> 68 + 69 + <span>@RenderDate(DateTime.Parse(NotificationResponse.CreatedAt))</span> 81 70 </div> 82 - 83 - <span>@RenderDate(DateTime.Parse(NotificationResponse.CreatedAt))</span> 84 - </div> 71 + } 85 72 86 73 @if (NotificationResponse is { Note: not null }) 87 74 { 88 - <div @onclick="OpenNote" class="notification-note"> 89 - <Note NoteResponse="NotificationResponse.Note"/> 75 + <div @onclick="OpenNote" class="@(NotificationResponse is not { Type: "mention" } or { Type: "reply" } ? "notification-note" : "")"> 76 + <NoteComponent Note="NotificationResponse.Note" AsQuote="@(NotificationResponse is not { Type: "mention" } or { Type: "reply" })"/> 90 77 </div> 91 78 } 92 79 </div>
+2 -1
Iceshrimp.Frontend/Components/NotificationComponent.razor.css
··· 10 10 } 11 11 12 12 .notification-text { 13 + font-size: 0.8em; 13 14 } 14 15 15 16 .notification-note { ··· 29 30 object-fit: cover; 30 31 width: 3em; 31 32 height: 3em; 32 - margin-right: 0.5em; 33 + margin-right: 0.75em; 33 34 } 34 35 35 36 .display-name {