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] Add bite back button to bite notifications

pancakes 9475e76b 7630d1f8

+72
+31
Iceshrimp.Frontend/Components/NotificationComponent.razor
··· 4 4 @using Iceshrimp.Shared.Schemas.Web 5 5 @using Microsoft.Extensions.Localization 6 6 @using Iceshrimp.Assets.PhosphorIcons 7 + @using Iceshrimp.Frontend.Core.Miscellaneous 8 + @using Iceshrimp.Frontend.Core.Services 9 + @inject ApiService Api; 10 + @inject GlobalComponentSvc Global; 7 11 @inject IStringLocalizer<Localization> Loc; 8 12 @inject NavigationManager NavigationManager 9 13 ··· 108 112 <NoteComponent Note="NotificationResponse.Note" AsQuote="@(NotificationResponse is not { Type: "mention" } or { Type: "reply" })" OpenNote="true"/> 109 113 </div> 110 114 } 115 + 116 + @switch (NotificationResponse) 117 + { 118 + case { Type: "bite", Bite: not null, User: not null }: 119 + <div class="notification-actions"> 120 + <button class="button" @onclick="BiteBack"> 121 + <Icon Name="Icons.Tooth"/> 122 + @Loc["Bite back"] 123 + </button> 124 + </div> 125 + break; 126 + } 111 127 </div> 112 128 113 129 @code { ··· 118 134 var username = $"@{NotificationResponse.User?.Username}"; 119 135 if (NotificationResponse.User?.Host != null) username += $"@{NotificationResponse.User.Host}"; 120 136 NavigationManager.NavigateTo($"/{username}"); 137 + } 138 + 139 + private async Task BiteBack() 140 + { 141 + if (NotificationResponse is not { Bite: { } bite, User: { } user }) return; 142 + 143 + try 144 + { 145 + await Api.Misc.BiteBackAsync(bite.Id); 146 + await Global.NoticeDialog?.Display(Loc["Bit {0} back", user.DisplayName ?? user.Username])!; 147 + } 148 + catch (ApiException e) 149 + { 150 + await Global.NoticeDialog?.Display(e.Response.Message ?? Loc["Unable to bite {0}", user.DisplayName ?? user.Username], NoticeDialog.NoticeType.Error)!; 151 + } 121 152 } 122 153 }
+38
Iceshrimp.Frontend/Components/NotificationComponent.razor.css
··· 91 91 .notification-header { 92 92 display: flex; 93 93 width: 100%; 94 + } 95 + 96 + .notification-actions { 97 + display: flex; 98 + flex-wrap: wrap; 99 + gap: 0.5rem; 100 + margin-top: 1rem; 101 + } 102 + 103 + .button { 104 + display: inline-flex; 105 + align-items: center; 106 + height: 2em; 107 + margin: 0; 108 + padding: 0.75em; 109 + background-color: var(--foreground-color); 110 + color: var(--notice-color); 111 + border: 0.1rem solid var(--foreground-color); 112 + width: fit-content; 113 + cursor: pointer; 114 + } 115 + 116 + .button.danger { 117 + color: var(--danger-color); 118 + } 119 + 120 + .button:hover { 121 + transition: 250ms; 122 + border-color: var(--notice-color); 123 + background-color: var(--hover-color); 124 + } 125 + 126 + .button.danger:hover { 127 + border-color: var(--danger-color); 128 + } 129 + 130 + ::deep .button .ph { 131 + margin-right: 0.5rem; 94 132 }
+3
Iceshrimp.Frontend/Core/ControllerModels/MiscControllerModel.cs
··· 6 6 7 7 internal class MiscControllerModel(ApiClient api) 8 8 { 9 + public Task BiteBackAsync(string id) => 10 + api.CallAsync(HttpMethod.Post, $"/misc/bite_back/{id}"); 11 + 9 12 public Task<IEnumerable<NoteResponse>> GetMutedThreadsAsync(PaginationQuery pq) => 10 13 api.CallAsync<IEnumerable<NoteResponse>>(HttpMethod.Get, "/misc/muted_threads", pq); 11 14