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] Add note timestamp that links to note in public preview

authored by

pancakes and committed by
Iceshrimp development
4d29e8f0 6e855b55

+44 -14
+24
Iceshrimp.Backend/Components/Generic/Timestamp.razor
··· 1 + @using Iceshrimp.Backend.Core.Extensions 2 + 3 + <span title="@Date.ToDisplayStringTz()">@RenderTimestamp()</span> 4 + 5 + @code { 6 + [Parameter, EditorRequired] public required DateTime Date { get; set; } 7 + 8 + private string RenderTimestamp() 9 + { 10 + var diff = DateTime.UtcNow - Date.ToUniversalTime(); 11 + 12 + return diff switch 13 + { 14 + { TotalDays: >= 365 } => $"{Math.Floor(diff.TotalDays / 365)}y", 15 + { TotalDays: >= 30 } => $"{Math.Floor(diff.TotalDays / 30)}mo", 16 + { TotalDays: >= 7 } => $"{Math.Floor(diff.TotalDays / 7)}w", 17 + { TotalDays: >= 1 } => $"{Math.Floor(diff.TotalDays)}d", 18 + { TotalHours: >= 1 } => $"{Math.Floor(diff.TotalHours)}h", 19 + { TotalMinutes: >= 1 } => $"{Math.Floor(diff.TotalMinutes)}m", 20 + { TotalSeconds: >= 5 } => $"{Math.Floor(diff.TotalSeconds)}s", 21 + _ => "now" 22 + }; 23 + } 24 + }
+7 -10
Iceshrimp.Backend/Components/PublicPreview/NoteComponent.razor
··· 1 + @using Iceshrimp.Backend.Components.Generic 1 2 @using Iceshrimp.Backend.Components.PublicPreview.Schemas 2 3 3 4 <div class="note"> 4 - <UserComponent User="Note.User" Link="true"/> 5 - 6 - <!-- TODO: figure out a better place to put this 7 - <small>Published at: @Note.CreatedAt</small> 8 - @if (Note.UpdatedAt != null) 9 - { 10 - <br/> 11 - <small>Edited at: @Note.UpdatedAt</small> 12 - } 13 - --> 5 + <div class="note-details"> 6 + <UserComponent User="Note.User" Link="true"/> 7 + <a href="/notes/@Note.Id"> 8 + <Timestamp Date="@Note.CreatedAt"/> 9 + </a> 10 + </div> 14 11 15 12 <div class="content"> 16 13 @if (Note.Cw != null)
+7
Iceshrimp.Backend/Components/PublicPreview/NoteComponent.razor.css
··· 5 5 border-radius: 0.75rem; 6 6 } 7 7 8 + .note-details { 9 + display: flex; 10 + flex-direction: row; 11 + gap: 1rem; 12 + justify-content: space-between; 13 + } 14 + 8 15 .content { 9 16 display: flex; 10 17 flex-direction: column;
+3 -2
Iceshrimp.Backend/Components/PublicPreview/Renderers/NoteRenderer.cs
··· 44 44 45 45 var res = new PreviewNote 46 46 { 47 + Id = note.Id, 47 48 User = users.First(p => p.Id == note.User.Id), 48 49 Text = renderedText?.Html, 49 50 Cw = note.Cw, ··· 53 54 QuoteInaccessible = note.Renote?.VisibilityIsPublicOrHome == false, 54 55 Attachments = attachments[note.Id]?.Where(p => !inlineMediaUrls.Contains(p.Url)).ToList(), 55 56 Poll = polls.GetValueOrDefault(note.Id), 56 - CreatedAt = note.CreatedAt.ToDisplayStringTz(), 57 - UpdatedAt = note.UpdatedAt?.ToDisplayStringTz() 57 + CreatedAt = note.CreatedAt, 58 + UpdatedAt = note.UpdatedAt 58 59 }; 59 60 60 61 return res;
+3 -2
Iceshrimp.Backend/Components/PublicPreview/Schemas/PreviewNote.cs
··· 4 4 5 5 public class PreviewNote 6 6 { 7 + public required string Id; 7 8 public required PreviewUser User; 8 9 public required string? RawText; 9 10 public required MarkupString? Text; ··· 13 14 public required bool QuoteInaccessible; 14 15 public required List<PreviewAttachment>? Attachments; 15 16 public required PreviewPoll? Poll; 16 - public required string CreatedAt; 17 - public required string? UpdatedAt; 17 + public required DateTime CreatedAt; 18 + public required DateTime? UpdatedAt; 18 19 } 19 20 20 21 public class PreviewAttachment