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