diff --git a/Components/Layout/AvatarMenu.razor b/Components/Layout/AvatarMenu.razor index 3e74d6e..c334f0c 100644 --- a/Components/Layout/AvatarMenu.razor +++ b/Components/Layout/AvatarMenu.razor @@ -10,6 +10,10 @@ 👋 Hey, @State.Name. + + + Address Directory + @foreach (AddressResponseData address in State.AddressList ?? new List()) { @address.Address diff --git a/Components/Layout/NavLinks.razor b/Components/Layout/NavLinks.razor index acf4f7f..5fabb20 100644 --- a/Components/Layout/NavLinks.razor +++ b/Components/Layout/NavLinks.razor @@ -13,4 +13,8 @@
Now.garden
+
+ + +
Address Directory
\ No newline at end of file diff --git a/Components/Pages/Directory.razor b/Components/Pages/Directory.razor new file mode 100644 index 0000000..6296be5 --- /dev/null +++ b/Components/Pages/Directory.razor @@ -0,0 +1,44 @@ +@page "/directory" +@implements IDisposable +@inject IJSRuntime JS +@inject State State + + + + + Welcome to the
omg.lol member directory! Everyone here is awesome. + + +
+ + @if (addresses != null) { + @* TODO: Display avatar and address name, grouped by starting letter? *@ + } + + +
+ +@code { + private List? addresses; + + protected override async Task OnInitializedAsync() { + await base.OnInitializedAsync(); + if (addresses == null || addresses.Count == 0) addresses = await State.GetDirectory(); + State.PropertyChanged += StateChanged; + State.CanRefresh = true; + await InvokeAsync(StateHasChanged); + await JS.InvokeVoidAsync("removeElementById", "address-loading"); + } + + private async void StateChanged(object? sender, PropertyChangedEventArgs e) { + if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) { + addresses = await State.GetDirectory(true); + State.IsRefreshing = false; + } + } + + public void Dispose() { + State.PropertyChanged -= StateChanged; + State.CanRefresh = false; + } +} diff --git a/Models/DirectoryResponseData.cs b/Models/DirectoryResponseData.cs new file mode 100644 index 0000000..b46dd32 --- /dev/null +++ b/Models/DirectoryResponseData.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Neighbourhood.omg.lol.Models { + public class DirectoryResponseData : IOmgLolResponseData { + public string Message { get; set; } + public string Url { get; set; } + public List Directory { get; set; } + } +} diff --git a/Models/State.cs b/Models/State.cs index 9b13e1d..689776c 100644 --- a/Models/State.cs +++ b/Models/State.cs @@ -9,6 +9,7 @@ namespace Neighbourhood.omg.lol.Models { public List? Pics { get; set; } public List? NowGarden { get; set; } public List? EphemeralMessages { get; set; } + public List? AddressDirectory { get; set; } // Account data public AccountResponseData? AccountInfo { get; set; } @@ -143,6 +144,13 @@ namespace Neighbourhood.omg.lol.Models { return this.EphemeralMessages; } + public async Task?> GetDirectory(bool forceRefresh = false) { + if (forceRefresh || this.AddressDirectory == null || this.AddressDirectory.Count == 0) { + this.AddressDirectory = await api.Directory(); + } + return this.AddressDirectory; + } + public async Task?> GetStatuses(bool forceRefresh = false) { if (forceRefresh || this.Statuses == null || this.Statuses.Count == 0) { this.Statuses = await api.StatuslogLatest(); diff --git a/RestService.cs b/RestService.cs index 4702dda..ac670fe 100644 --- a/RestService.cs +++ b/RestService.cs @@ -174,10 +174,12 @@ namespace Neighbourhood.omg.lol { public async Task PatchStatus(string address, string id, string content, string? emoji) => (await Patch($"/address/{address}/statuses/", new PatchStatus { Id = id, Content = content, Emoji = emoji })); - public async Task?> NowGarden() => (await Get($"/now/garden"))?.Garden ?? new List(); + public async Task?> Directory() => + (await Get($"/directory"))?.Directory ?? new List(); + public async Task> Ephemeral() { List notes = new List(); Uri Uri = new Uri($"https://eph.emer.al/"); diff --git a/wwwroot/css/style.css b/wwwroot/css/style.css index 4f3a5c9..33116a0 100644 --- a/wwwroot/css/style.css +++ b/wwwroot/css/style.css @@ -218,10 +218,11 @@ dialog { padding:0; } -@media only screen and (max-width: 600px) { +@media only screen and (max-width: 992px) { .fab { bottom: 7rem; } + *:has(> main.responsive) { /*flex-direction: row;*/ max-block-size: calc(100vh - 5rem); @@ -378,12 +379,16 @@ a.row.indent { /* s */ @media only screen and (max-width: 600px) { - + .m:not(.s), .l:not(.s), .m.l:not(.s) { + display: none !important; + } } /* m */ @media only screen and (min-width: 601px) and (max-width: 992px) { - + .s:not(.m), .l:not(.m), .s.l:not(.m) { + display: none !important; + } } /* l */