From 8c8634f3c3a7757adcec7f4c9c35fb3843746e22 Mon Sep 17 00:00:00 2001 From: Gordon Pedersen Date: Thu, 13 Jun 2024 20:02:51 +1000 Subject: [PATCH] Fixes and editing statuses --- Components/EditStatusDialog.razor | 88 ++++++++++++++++++++++++ Components/Pages/Person.razor | 17 ++++- Components/PicCard.razor | 2 +- Components/PicCardEditableTemplate.razor | 30 -------- Components/PicCardTemplate.razor | 23 ------- Components/StatusCard.razor | 33 ++++++--- Components/StatusList.razor | 8 ++- Models/PatchStatus.cs | 13 ++++ Models/PatchStatusResponseData.cs | 13 ++++ RestService.cs | 23 +++++++ wwwroot/css/style.css | 11 ++- 11 files changed, 193 insertions(+), 68 deletions(-) create mode 100644 Components/EditStatusDialog.razor delete mode 100644 Components/PicCardEditableTemplate.razor delete mode 100644 Components/PicCardTemplate.razor create mode 100644 Models/PatchStatus.cs create mode 100644 Models/PatchStatusResponseData.cs diff --git a/Components/EditStatusDialog.razor b/Components/EditStatusDialog.razor new file mode 100644 index 0000000..5f1d270 --- /dev/null +++ b/Components/EditStatusDialog.razor @@ -0,0 +1,88 @@ +@inject IJSRuntime JS +@inject State State + +
+ +
+
+ +
+
+ + +
+
+ +
+ +@code { + private Status? _status; + + public Status? Status { + get => _status; + set { + _status = value; + Content = _status?.Content; + Emoji = _status?.Emoji; + InvokeAsync(StateHasChanged); + } + } + public string? Content { get; set; } + public string? Emoji { get; set; } + private bool loading = false; + [Parameter] + public string id { get; set; } + + protected override async Task OnInitializedAsync() { + Content = Status?.Content; + Emoji = Status?.Emoji; + } + + public async Task PatchStatus() { + loading = true; + await InvokeAsync(StateHasChanged); + + RestService api = new RestService(); + if (!string.IsNullOrEmpty(Status?.Id)) { + await api.PatchStatus(State.SelectedAddressName, Status.Id, Content, Emoji); + await State.RefreshStatuses(); + await InvokeAsync(StateHasChanged); + } + + await JS.InvokeVoidAsync("ui", "#" + id); + // clear input + Content = string.Empty; + Emoji = string.Empty; + Status = null; + loading = false; + await InvokeAsync(StateHasChanged); + + } +} diff --git a/Components/Pages/Person.razor b/Components/Pages/Person.razor index 64e2d90..988da5c 100644 --- a/Components/Pages/Person.razor +++ b/Components/Pages/Person.razor @@ -51,11 +51,11 @@ } - +
- +
@if(now != null){
@@ -66,8 +66,16 @@
@code { + private string _address; [Parameter] - public string Address { get; set; } + public string Address { + get => _address; + set { + _address = value; + if(StatusList != null) StatusList.StatusFunc = async () => await State.GetStatuses(_address); + if(PicList != null) PicList.PicsFunc = async () => await State.GetPics(_address); + } + } public string ProfileUrl { get => $"https://{Address}.omg.lol/"; } @@ -75,6 +83,9 @@ public ExternalPageComponent? NowPage { get; set; } public ExternalPageComponent? ProfilePage { get; set; } + private StatusList StatusList { get; set; } + private PicList PicList { get; set; } + private bool Editable { get => Address == State.SelectedAddressName; } diff --git a/Components/PicCard.razor b/Components/PicCard.razor index 2ca63d6..5ff09f7 100644 --- a/Components/PicCard.razor +++ b/Components/PicCard.razor @@ -28,7 +28,7 @@ @code { [Parameter] public Pic Pic {get; set;} - [Parameter] + [Parameter] public bool Editable { get; set; } = false; [Parameter] public EditPicDialog? Dialog { get; set; } diff --git a/Components/PicCardEditableTemplate.razor b/Components/PicCardEditableTemplate.razor deleted file mode 100644 index ecc8b8f..0000000 --- a/Components/PicCardEditableTemplate.razor +++ /dev/null @@ -1,30 +0,0 @@ - \ No newline at end of file diff --git a/Components/PicCardTemplate.razor b/Components/PicCardTemplate.razor deleted file mode 100644 index ea1f98e..0000000 --- a/Components/PicCardTemplate.razor +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/Components/StatusCard.razor b/Components/StatusCard.razor index 9379fcb..dc38226 100644 --- a/Components/StatusCard.razor +++ b/Components/StatusCard.razor @@ -1,19 +1,24 @@ -
+@inject IJSRuntime JS + +
-
@status.EmojiOrDefault
+
@Status.EmojiOrDefault
- - @status.Address + + @Status.Address - @status.HtmlContent + @Status.HtmlContent