Fixes to the pic list

This commit is contained in:
Gordon Pedersen 2024-06-13 10:26:43 +10:00
parent d0d3d2cc00
commit 08788db7fa
5 changed files with 32 additions and 4 deletions

View file

@ -17,7 +17,7 @@
<i class="fa-solid fa-share-nodes"></i>
</button>
</nav>
<p class="description">{{Pic.Description}}</p>
<p class="description">{{Pic.DescriptionHtml}}</p>
</div>
</article>
</template>

View file

@ -1,4 +1,5 @@
@inject IJSRuntime JS
@inject State State
@if (Editable) {
<PicCardEditableTemplate></PicCardEditableTemplate>
@ -28,6 +29,7 @@ else {
html = html.replaceAll("{{Pic.Address}}", pic.address)
html = html.replaceAll("{{Pic.RelativeTime}}", pic.relativeTime)
html = html.replaceAll("{{Pic.Description}}", pic.description)
html = html.replaceAll("{{Pic.DescriptionHtml}}", pic.descriptionHtml)
clone.children[0].innerHTML = html
@ -64,20 +66,26 @@ else {
private DotNetObjectReference<PicList>? objRef;
protected override void OnInitialized() {
base.OnInitialized();
objRef = DotNetObjectReference.Create(this);
State.CurrentPage = Page.Pics;
}
protected override async Task OnAfterRenderAsync(bool firstRender) {
await base.OnAfterRenderAsync(firstRender);
if (firstRender) {
await JS.InvokeVoidAsync("injectCSharp", objRef);
RestService api = new RestService();
if (State.CurrentPage != Page.Pics) return;
if (pics == null || pics.Count == 0) pics = await PicsFunc();
if (State.CurrentPage != Page.Pics) return;
int page_size = 1;
for (int i = 0; i < pics.Count; i += page_size) {
if (State.CurrentPage != Page.Pics) return;
await JS.InvokeVoidAsync("renderPics", pics.Skip(i * page_size).Take(page_size));
if (State.CurrentPage != Page.Pics) return;
}
if (State.CurrentPage != Page.Pics) return;
await JS.InvokeVoidAsync("clearLoading");
}
}

View file

@ -1,4 +1,5 @@
<Virtualize ItemsProvider="GetStatuses" Context="status" ItemSize="180">
@inject State State
<Virtualize ItemsProvider="GetStatuses" Context="status" ItemSize="180">
<ItemContent>
<StatusCard status="@status"></StatusCard>
</ItemContent>
@ -14,4 +15,9 @@
private async ValueTask<ItemsProviderResult<Status>> GetStatuses(ItemsProviderRequest request) {
return await this.StatusFunc(request);
}
protected override void OnInitialized() {
base.OnInitialized();
State.CurrentPage = Page.Status;
}
}

View file

@ -1,4 +1,6 @@
using System;
using Markdig;
using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -15,6 +17,7 @@ namespace Neighbourhood.omg.lol.Models {
public long Size { get; set; }
public string Mime { get; set; }
public string Description { get; set; }
public string DescriptionHtml { get => Markdown.ToHtml(Description); }
[JsonPropertyName("exif")]
public JsonElement ExifJson { get; set; }

View file

@ -11,6 +11,8 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models {
public class State {
public Page CurrentPage { get; set; }
public AccountResponseData? AccountInfo { get; set; }
public AddressResponseList? AddressList { get; set; }
@ -205,4 +207,13 @@ namespace Neighbourhood.omg.lol.Models {
return offsetString;
}
}
public enum Page {
None = 0,
Status,
Pics,
Ephemeral,
Person,
Other
}
}