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/pages] Display pinned notes on user profiles

authored by

pancakes and committed by
Iceshrimp development
8729063b 11bcb753

+63 -5
+4
Iceshrimp.Frontend/Core/ControllerModels/UserControllerModel.cs
··· 16 16 public Task<List<NoteResponse>?> GetUserNotesAsync(string id, PaginationQuery pq) => 17 17 api.CallNullableAsync<List<NoteResponse>>(HttpMethod.Get, $"/users/{id}/notes", pq); 18 18 19 + [LinkPagination(20, 80)] 20 + public Task<List<NoteResponse>?> GetUserPinnedNotesAsync(string id, PaginationQuery pq) => 21 + api.CallNullableAsync<List<NoteResponse>>(HttpMethod.Get, $"/users/{id}/pinned_notes", pq); 22 + 19 23 public Task<UserResponse?> LookupUserAsync(string username, string? host) 20 24 { 21 25 var query = new QueryString();
+48 -5
Iceshrimp.Frontend/Pages/ProfileView.razor
··· 159 159 </div> 160 160 <ProfileInfo Emojis="@UserResponse.Emojis" User="UserResponse" UserProfile="Profile"/> 161 161 </div> 162 + @if (UserPinned.Count > 0) 163 + { 164 + <LabeledRuler Label="@Loc["Pinned notes"]"/> 165 + <div class="notes"> 166 + @foreach (var note in UserPinned) 167 + { 168 + <div class="note-container"> 169 + <Note NoteResponse="note" OpenNote="true"/> 170 + </div> 171 + } 172 + </div> 173 + <span class="pinned-end"> 174 + <ScrollEnd IntersectionChange="AddPinnedNotes" ManualLoad="AddPinnedNotes" Class="end"/> 175 + </span> 176 + <LabeledRuler Label="@Loc["Latest notes"]"/> 177 + } 162 178 @if (UserNotes.Count > 0) 163 179 { 164 180 <div class="notes"> ··· 197 213 [Parameter] public string? Host { get; set; } 198 214 private UserResponse UserResponse { get; set; } = null!; 199 215 private UserProfileResponse? Profile { get; set; } 216 + private string? PinnedMinId { get; set; } 200 217 private string? MinId { get; set; } 218 + private List<NoteResponse> UserPinned { get; set; } = []; 201 219 private List<NoteResponse> UserNotes { get; set; } = []; 202 220 203 221 private ElementReference MenuButton { get; set; } ··· 222 240 StateHasChanged(); 223 241 } 224 242 } 243 + 244 + private async Task GetPinnedNotes(string? minId) 245 + { 246 + var pq = new PaginationQuery { Limit = 10, MaxId = minId }; 247 + var notes = await Api.Users.GetUserPinnedNotesAsync(UserResponse.Id, pq); 248 + if (notes is not null && notes.Count > 0) 249 + { 250 + PinnedMinId = notes.Last().Id; 251 + UserPinned.AddRange(notes); 252 + StateHasChanged(); 253 + } 254 + } 255 + 256 + private async Task AddPinnedNotes() 257 + { 258 + if (_fetchLock == false) 259 + { 260 + _fetchLock = true; 261 + await GetPinnedNotes(PinnedMinId); 262 + _fetchLock = false; 263 + } 264 + } 225 265 226 266 private async Task AddNotes() 227 267 { ··· 254 294 { 255 295 UserResponse = userResponse; 256 296 Profile = await Api.Users.GetUserProfileAsync(UserResponse.Id); 297 + await GetPinnedNotes(null); 257 298 await GetNotes(null); 258 299 _init = true; 259 300 _loading = false; ··· 269 310 270 311 protected override async Task OnParametersSetAsync() 271 312 { 272 - _init = false; 273 - _loading = true; 274 - UserNotes = []; 275 - MinId = null; 276 - Profile = null; 313 + _init = false; 314 + _loading = true; 315 + UserPinned = []; 316 + UserNotes = []; 317 + PinnedMinId = null; 318 + MinId = null; 319 + Profile = null; 277 320 StateHasChanged(); 278 321 await LoadProfile(); 279 322 _instance = await MetadataService.Instance.Value;
+11
Iceshrimp.Frontend/Pages/ProfileView.razor.css
··· 105 105 overflow: clip; 106 106 } 107 107 108 + ::deep .labeled-ruler { 109 + margin-top: 1rem; 110 + margin-left: auto; 111 + margin-right: auto; 112 + max-width: 45rem; 113 + } 114 + 108 115 ::deep .end { 109 116 display: flex; 110 117 flex-direction: column; 111 118 align-items: center; 112 119 } 120 + 121 + ::deep .pinned-end .end button { 122 + display: none; 123 + }