[frontend] Add visibility dropdown to compose menu, render reply to support to compose

This commit is contained in:
Lilian 2024-05-15 19:52:01 +02:00
parent 74355e8332
commit 727a4dfe88
No known key found for this signature in database
GPG key ID: 007CA12D692829E1
7 changed files with 46 additions and 4 deletions

View file

@ -1,8 +1,11 @@
@using FParsec
@using Iceshrimp.Assets.PhosphorIcons
@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Shared.Schemas
@using Iceshrimp.Frontend.Components.Note
@inject IJSRuntime Js
@inject ApiService ApiService
@inject ComposeService ComposeService
<dialog class="compose" @ref="Dialog">
<div class="header">
<button @onclick="CloseDialog">
@ -12,6 +15,12 @@
</Dropdown>
<button @onclick="SendNote" class="post-btn">Post<Icon Name="Icons.PaperPlaneRight"/></button>
</div>
@if (ReplyTo != null)
{
<div class="reply-to">
<NoteComponent Note="ReplyTo" AsQuote="true" />
</div>
}
@if (NoteDraft.Cw != null)
{
<input @bind="NoteDraft.Cw" class="input cw-field" placeholder="Content Warning"/>
@ -36,6 +45,7 @@
private IJSObjectReference? _module;
private IList<DriveFileResponse> Attachments { get; set; } = [];
private InputFile UploadInput { get; set; }
private NoteBase? ReplyTo { get; set; }
private NoteCreateRequest NoteDraft { get; set; } = new NoteCreateRequest
{
@ -83,8 +93,15 @@
await _module.InvokeVoidAsync("openUpload", UploadInput.Element);
}
public async Task OpenDialog()
public async Task OpenDialog(NoteBase? replyTo = null)
{
if (replyTo != null)
{
ReplyTo = replyTo;
NoteDraft.ReplyId = replyTo.Id;
StateHasChanged();
}
await _module.InvokeVoidAsync("openDialog", Dialog);
}
@ -124,6 +141,7 @@
{
_module = await Js.InvokeAsync<IJSObjectReference>("import",
"./Components/Compose.razor.js");
ComposeService.ComposeDialog = this;
}
}

View file

@ -48,3 +48,8 @@
.file-input {
display: none;
}
.reply-to {
border: solid var(--highlight-color) 0.1rem;
border-radius: 0.75rem;
padding: 0.5rem;
}

View file

@ -8,3 +8,7 @@
border-width: 0.1rem;
border-radius: 0.5rem;
}
.dropdown-root {
display: inline-block
}

View file

@ -1,7 +1,8 @@
@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Shared.Schemas
@inject ApiService ApiService;
@inject ApiService ApiService;
@inject NavigationManager NavigationManager
@inject ComposeService ComposeService
<CascadingValue Value="this">
<div class="note-header">
<NoteUserInfo
@ -84,4 +85,9 @@
StateHasChanged();
}
}
public void Reply()
{
ComposeService.ComposeDialog?.OpenDialog(Note);
}
}

View file

@ -10,7 +10,7 @@
}
</div>
}
<button class="btn" @onclick:stopPropagation="true">
<button class="btn" @onclick="Reply" @onclick:stopPropagation="true">
<Icon Name="Icons.ArrowUUpLeft" Size="1.3em"/>
</button>
<button class="btn" @onclick:stopPropagation="true">
@ -46,4 +46,9 @@
{
NoteComponent.Like();
}
private void Reply()
{
NoteComponent.Reply();
}
}

View file

@ -1,6 +1,9 @@
using Iceshrimp.Frontend.Components;
using Microsoft.AspNetCore.Components;
namespace Iceshrimp.Frontend.Core.Services;
public class ComposeService
{
public Compose? ComposeDialog { get; set; }
}

View file

@ -17,6 +17,7 @@ builder.Services.AddIntersectionObserver();
builder.Services.AddSingleton<SessionService>();
builder.Services.AddSingleton<StreamingService>();
builder.Services.AddScoped<AuthenticationStateProvider, CustomAuthStateProvider>();
builder.Services.AddSingleton<ComposeService>();
builder.Services.AddAuthorizationCore();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddBlazoredLocalStorageAsSingleton();