From 8a7bcde0c33eed49f5b2a71d6a825191153d1c7e Mon Sep 17 00:00:00 2001 From: Lilian Date: Thu, 28 Nov 2024 21:11:15 +0100 Subject: [PATCH] [frontend/components] Scroll to attachment that was clicked on (ISH-641) --- .../Components/AttachmentComponent.razor | 17 +++++++++-------- .../Components/AttachmentView.razor | 4 +++- .../Components/Note/NoteAttachments.razor | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Iceshrimp.Frontend/Components/AttachmentComponent.razor b/Iceshrimp.Frontend/Components/AttachmentComponent.razor index 523b9654..f52b0d56 100644 --- a/Iceshrimp.Frontend/Components/AttachmentComponent.razor +++ b/Iceshrimp.Frontend/Components/AttachmentComponent.razor @@ -8,12 +8,13 @@
@if (Attachment.ContentType.StartsWith("image")) { - @Attachment.AltText + @Attachment.AltText } -// else if (Attachment.ContentType == "audio/x-mod") -// { -// TODO: Module player -// } + // else if (Attachment.ContentType == "audio/x-mod") + // { + // TODO: Module player + // } else if (Attachment.ContentType.StartsWith("audio")) { @@ -49,8 +50,8 @@
@code { - [Parameter] [EditorRequired] public required NoteAttachment Attachment { get; set; } - [Parameter] [EditorRequired] public required EventCallback OnOpen { get; set; } + [Parameter] [EditorRequired] public required NoteAttachment Attachment { get; set; } + [Parameter] [EditorRequired] public required EventCallback OnOpen { get; set; } private bool BlurImage { get; set; } @@ -63,7 +64,7 @@ } else { - OnOpen.InvokeAsync(); + OnOpen.InvokeAsync(Attachment); } } diff --git a/Iceshrimp.Frontend/Components/AttachmentView.razor b/Iceshrimp.Frontend/Components/AttachmentView.razor index c1e97e72..6dad1177 100644 --- a/Iceshrimp.Frontend/Components/AttachmentView.razor +++ b/Iceshrimp.Frontend/Components/AttachmentView.razor @@ -81,10 +81,12 @@ await Module.InvokeVoidAsync("scrollTo", _refs[Focused]); } - public async Task OpenDialog() + public async Task OpenDialog(NoteAttachment attachment) { await Module.InvokeVoidAsync("openDialog", Dialog); ScrollWidth = await Module.InvokeAsync("getScrollWidth", Scroller); + var index = Attachments.IndexOf(attachment); + await Module.InvokeVoidAsync("scrollTo", _refs[index]); } private async Task CloseDialog() diff --git a/Iceshrimp.Frontend/Components/Note/NoteAttachments.razor b/Iceshrimp.Frontend/Components/Note/NoteAttachments.razor index 337545ec..c86b7a54 100644 --- a/Iceshrimp.Frontend/Components/Note/NoteAttachments.razor +++ b/Iceshrimp.Frontend/Components/Note/NoteAttachments.razor @@ -11,8 +11,8 @@ [Parameter] [EditorRequired] public required IList Attachments { get; set; } private AttachmentView View { get; set; } = null!; - private async Task Open() + private async Task Open(NoteAttachment attachment) { - await View.OpenDialog(); + await View.OpenDialog(attachment); } } \ No newline at end of file