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.

[backend/razor] Show user notes with pagination in profile public preview

authored by

pancakes and committed by
Iceshrimp development
6e855b55 a9cb8a63

+60 -1
+33
Iceshrimp.Backend/Pages/UserPreview.razor
··· 104 104 { 105 105 <NoteComponent Note="note" ShowMedia="false"/> 106 106 } 107 + @if (_pinnedNotes.Count != 0 && _notes.Count != 0) 108 + { 109 + <LabeledRuler Label="Latest notes"/> 110 + } 111 + @foreach (var note in _notes) 112 + { 113 + <NoteComponent Note="note" ShowMedia="false"/> 114 + } 115 + 116 + <div class="pagination"> 117 + @if (Offset is > 0) 118 + { 119 + <button class="button" role="link" data-target="/@@@Acct?offset=@(Math.Max(0, Offset.Value - 20))" 120 + onclick="navigate(event)">❮ Previous page 121 + </button> 122 + } 123 + else 124 + { 125 + <button class="button" disabled>❮ Previous page</button> 126 + } 127 + 128 + @if (_notes.Count == 20) 129 + { 130 + <button class="button" role="link" data-target="/@@@Acct?offset=@((Offset ?? 0) + 20)" onclick="navigate(event)"> 131 + Next page ❯ 132 + </button> 133 + } 134 + else 135 + { 136 + <button class="button" disabled>Next page ❯</button> 137 + } 138 + </div> 107 139 108 140 <PageTitle>@@@_user.Username - @_instanceName</PageTitle> 109 141 <HeadContent> ··· 125 157 } 126 158 <VersionedLink rel="stylesheet" href="/_content/Iceshrimp.Assets.PhosphorIcons/css/ph-regular.css"/> 127 159 <VersionedLink rel="stylesheet" href="/css/public-preview.css"/> 160 + <VersionedScript src="/js/user-preview.js"/> 128 161 </HeadContent> 129 162 }
+14 -1
Iceshrimp.Backend/Pages/UserPreview.razor.cs
··· 22 22 { 23 23 [Parameter] public required string Acct { get; set; } 24 24 25 + [SupplyParameterFromQuery] public int? Offset { get; set; } 26 + 25 27 private PreviewUser? _user; 26 28 private string _instanceName = "Iceshrimp.NET"; 27 29 private string? _pronouns; ··· 32 34 private List<(string Name, string Value, bool? IsVerified)> _fields = []; 33 35 34 36 private List<PreviewNote> _pinnedNotes = []; 37 + private List<PreviewNote> _notes = []; 35 38 36 39 private Dictionary<string, (string, string)>? _feeds; 37 40 ··· 68 71 return; 69 72 } 70 73 71 - if (user != null && security.Value.PublicPreview != Enums.PublicPreview.Lockdown) 74 + if (user != null && Offset is 0 or null && security.Value.PublicPreview != Enums.PublicPreview.Lockdown) 72 75 { 73 76 var pinnedNotes = await Database.UserNotePins 74 77 .Where(p => p.UserId == user.Id && p.Note.VisibilityIsPublicOrHome) 75 78 .Select(p => p.Note) 76 79 .ToListAsync(); 77 80 _pinnedNotes = await noteRenderer.RenderManyAsync(pinnedNotes); 81 + } 82 + 83 + if (user != null && security.Value.PublicPreview != Enums.PublicPreview.Lockdown) 84 + { 85 + var notes = await Database.Notes 86 + .Where(p => p.UserId == user.Id && !p.IsPureRenote && p.VisibilityIsPublicOrHome) 87 + .Skip(Offset ?? 0) 88 + .Take(20) 89 + .ToListAsync(); 90 + _notes = await noteRenderer.RenderManyAsync(notes); 78 91 } 79 92 80 93 _user = await renderer.RenderOne(user);
+6
Iceshrimp.Backend/Pages/UserPreview.razor.css
··· 72 72 .field .field-value { 73 73 width: calc(100% - 10.5rem); 74 74 word-wrap: break-word; 75 + } 76 + 77 + .pagination { 78 + display: flex; 79 + flex-direction: row; 80 + justify-content: space-between; 75 81 }
+7
Iceshrimp.Backend/wwwroot/js/user-preview.js
··· 1 + function navigate(event) { 2 + const target = event.target.getAttribute('data-target') 3 + if (event.ctrlKey || event.metaKey) 4 + window.open(target, '_blank'); 5 + else 6 + window.location.href = target; 7 + }