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] Add bookmarks page

authored by

pancakes and committed by
Laura Hausmann
3994b3db ffaeebc2

+92 -7
+4
Iceshrimp.Frontend/Core/ControllerModels/TimelineControllerModel.cs
··· 27 27 api.CallAsync<List<NoteResponse>>(HttpMethod.Get, "/timelines/global", pq); 28 28 29 29 [LinkPagination(20, 80)] 30 + public Task<List<NoteResponse>> GetBookmarksTimelineAsync(PaginationQuery pq) => 31 + api.CallAsync<List<NoteResponse>>(HttpMethod.Get, "/timelines/bookmarks", pq); 32 + 33 + [LinkPagination(20, 80)] 30 34 public Task<List<NoteResponse>> GetRemoteTimelineAsync(string instance, PaginationQuery pq) => 31 35 api.CallAsync<List<NoteResponse>>(HttpMethod.Get, $"/timelines/remote/{instance}", pq); 32 36 }
+8 -7
Iceshrimp.Frontend/Core/Services/NoteStore/TimelineStore.cs
··· 100 100 { 101 101 var res = timeline.Enum switch 102 102 { 103 - TimelineEnum.Home => await _api.Timelines.GetHomeTimelineAsync(pq), 104 - TimelineEnum.Local => await _api.Timelines.GetLocalTimelineAsync(pq), 105 - TimelineEnum.Social => await _api.Timelines.GetSocialTimelineAsync(pq), 106 - TimelineEnum.Bubble => await _api.Timelines.GetBubbleTimelineAsync(pq), 107 - TimelineEnum.Global => await _api.Timelines.GetGlobalTimelineAsync(pq), 108 - TimelineEnum.Remote => await _api.Timelines.GetRemoteTimelineAsync(timeline.Remote!, pq), 109 - _ => throw new ArgumentOutOfRangeException(nameof(timeline), timeline, null) 103 + TimelineEnum.Home => await _api.Timelines.GetHomeTimelineAsync(pq), 104 + TimelineEnum.Local => await _api.Timelines.GetLocalTimelineAsync(pq), 105 + TimelineEnum.Social => await _api.Timelines.GetSocialTimelineAsync(pq), 106 + TimelineEnum.Bubble => await _api.Timelines.GetBubbleTimelineAsync(pq), 107 + TimelineEnum.Global => await _api.Timelines.GetGlobalTimelineAsync(pq), 108 + TimelineEnum.Bookmarks => await _api.Timelines.GetBookmarksTimelineAsync(pq), 109 + TimelineEnum.Remote => await _api.Timelines.GetRemoteTimelineAsync(timeline.Remote!, pq), 110 + _ => throw new ArgumentOutOfRangeException(nameof(timeline), timeline, null) 110 111 }; 111 112 112 113 if (Timelines.ContainsKey(timeline.Key) is false)
+6
Iceshrimp.Frontend/Layout/Sidebar.razor
··· 36 36 <span class="text">@Loc["Search"]</span> 37 37 </div> 38 38 </NavLink> 39 + <NavLink href="/bookmarks"> 40 + <div class="sidebar-btn"> 41 + <Icon Name="Icons.BookmarkSimple"/> 42 + <span class="text">@Loc["Bookmarks"]</span> 43 + </div> 44 + </NavLink> 39 45 <NavLink href="/follow-requests"> 40 46 <div class="sidebar-btn"> 41 47 <Icon Name="Icons.HandWaving"/>
+70
Iceshrimp.Frontend/Pages/BookmarksPage.razor
··· 1 + @page "/bookmarks" 2 + @inject TimelineStore Store; 3 + @inject StateService State; 4 + @using Iceshrimp.Frontend.Core.Miscellaneous 5 + @using Iceshrimp.Shared.Schemas.Web 6 + @using Iceshrimp.Frontend.Core.Services.NoteStore 7 + @using Iceshrimp.Frontend.Enums 8 + @using Iceshrimp.Frontend.Localization 9 + @using Microsoft.AspNetCore.Authorization 10 + @using Microsoft.Extensions.Localization 11 + @using Microsoft.AspNetCore.Components.Sections 12 + @using Iceshrimp.Frontend.Components 13 + @using Iceshrimp.Assets.PhosphorIcons 14 + @using Iceshrimp.Frontend.Core.Services 15 + @using Iceshrimp.Shared.Helpers 16 + @attribute [Authorize] 17 + @inject IStringLocalizer<Localization> Loc; 18 + @implements IDisposable 19 + 20 + <HeadTitle Text="@Loc["Bookmarks"]"/> 21 + 22 + <SectionContent SectionName="top-bar"> 23 + <Icon Name="Icons.BookmarkSimple"></Icon> 24 + @Loc["Bookmarks"] 25 + </SectionContent> 26 + 27 + <div class="timeline"> 28 + @if (NoteResponses is not null && _loaded) 29 + { 30 + <VirtualScroller InitialItems="NoteResponses" ItemProvider="Provider" StateKey="@Timeline.Key" 31 + ItemProviderById="ItemProviderById" StreamingItemProvider="Store" @ref="VirtualScroller"> 32 + <ItemTemplate Context="note"> 33 + <CascadingValue Value="Store" TValue="NoteMessageProvider" Name="Provider"> 34 + <TimelineNote Note="note"></TimelineNote> 35 + </CascadingValue> 36 + </ItemTemplate> 37 + </VirtualScroller> 38 + } 39 + </div> 40 + 41 + @code { 42 + private bool _loaded; 43 + private List<NoteResponse>? NoteResponses { get; set; } 44 + private TimelineStore.Timeline Timeline { get; set; } = null!; 45 + private VirtualScroller<NoteResponse>? VirtualScroller { get; set; } 46 + 47 + protected override async Task OnInitializedAsync() 48 + { 49 + Timeline = new TimelineStore.Timeline(TimelineEnum.Bookmarks); 50 + NoteResponses = await Store.GetTimelineAsync(Timeline, new TimelineStore.Cursor { Direction = DirectionEnum.Older, Count = 20, Id = null }); 51 + _loaded = true; 52 + StateHasChanged(); 53 + } 54 + 55 + private async Task<List<NoteResponse>?> Provider(DirectionEnum direction, NoteResponse start) 56 + { 57 + var res = await Store.GetTimelineAsync(Timeline, new TimelineStore.Cursor { Direction = direction, Count = 10, Id = start.Id }); 58 + return res; 59 + } 60 + 61 + private List<NoteResponse> ItemProviderById(List<string> arg) 62 + { 63 + return Store.GetIdsFromTimeline(Timeline, arg); 64 + } 65 + 66 + public void Dispose() 67 + { 68 + State.TimelinePage.Current = Timeline; 69 + } 70 + }
+3
Iceshrimp.Frontend/Pages/BookmarksPage.razor.css
··· 1 + .timeline { 2 + overflow-anchor: none; 3 + }
+1
Iceshrimp.Shared/Helpers/TimelineEnum.cs
··· 7 7 Social, 8 8 Bubble, 9 9 Global, 10 + Bookmarks, 10 11 Remote 11 12 }