diff --git a/App.razor b/App.razor index 56aa443..abb2f19 100644 --- a/App.razor +++ b/App.razor @@ -10,18 +10,22 @@ } else { -

You are not authorized to access this resource.

+

@Localizer["You are not authorized to access this resource."]

} - Not found + @Localizer["Not found"] -

Sorry, there's nothing at this address.

+

@Localizer["Sorry, there's nothing at this address."]

- \ No newline at end of file + + +@code { + [Inject] CoalescingStringLocalizer Localizer { get; set; } +} diff --git a/ClientJsonContext.cs b/ClientJsonContext.cs new file mode 100644 index 0000000..3b27a6a --- /dev/null +++ b/ClientJsonContext.cs @@ -0,0 +1,36 @@ +using System.Text.Json.Serialization; + +using decePubClient.Models; + +using PrivaPub.ClientModels; + +namespace decePubClient; + +/// +/// Source-generated JSON metadata for the client's own types, used first by SUtility.DefaultSerializer (HTTP) and by +/// Blazored.LocalStorage (Program.cs). Register every type that crosses HTTP or is stored in localStorage here; types +/// missing from it still work through the reflection fallback. Names stay camelCase: wwwroot/js/theme.js reads +/// PublicCacheData.pageSettings straight from localStorage. +/// +[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + IgnoreReadOnlyProperties = true)] +[JsonSerializable(typeof(PublicCacheData))] +[JsonSerializable(typeof(PageSettings))] +[JsonSerializable(typeof(AuthData))] +[JsonSerializable(typeof(User))] +[JsonSerializable(typeof(UserClaim))] +[JsonSerializable(typeof(ActionBarFilter))] +[JsonSerializable(typeof(Message))] +[JsonSerializable(typeof(List))] +[JsonSerializable(typeof(MessageUser))] +[JsonSerializable(typeof(BoostingUser))] +[JsonSerializable(typeof(Media))] +[JsonSerializable(typeof(MessageForm))] +[JsonSerializable(typeof(UploadMedia))] +[JsonSerializable(typeof(ClientLogs))] +[JsonSerializable(typeof(ClientLogException))] +[JsonSerializable(typeof(ValidationErrors))] +[JsonSerializable(typeof(WebResult))] +public partial class ClientJsonContext : JsonSerializerContext +{ +} diff --git a/Components/ActionBar.razor b/Components/ActionBar.razor index 30f823d..ccde121 100644 --- a/Components/ActionBar.razor +++ b/Components/ActionBar.razor @@ -65,33 +65,38 @@ @code { - [CascadingParameter] CascadingState CascadingState { get; set; } [Parameter] public EventCallback OnMessageSubmit { get; set; } [Parameter] public EventCallback OnTimelineChanged { get; set; } [Parameter] public EventCallback OnTimeSortingChanged { get; set; } [Inject] ILocalStorageService LocalStorage { get; set; } - bool isPosting { get; set; } = false; + bool isPosting; ActionBarFilter Filters { get; set; } = new(); protected override async Task OnInitializedAsync() { var filters = await LocalStorage.GetItemAsync(nameof(ActionBarFilter)); - if (filters == default) - await LocalStorage.SetItemAsync(nameof(ActionBarFilter), Filters); - else + IsLoading = false; + if (filters is not null) + { Filters = filters; + return; + } + + await LocalStorage.SetItemAsync(nameof(ActionBarFilter), Filters); } void OpenCloseMessageForm() { isPosting = !isPosting; } + async Task OnTimelineChange(TimelineType timelineType) { Filters.TimelineType = timelineType; await LocalStorage.SetItemAsync(nameof(ActionBarFilter), Filters); await OnTimelineChanged.InvokeAsync(Filters.TimelineType); } + async Task OnTimeSortChange(TimeSortingType timeSorting) { Filters.TimeSortingType = timeSorting; diff --git a/Components/Content.razor b/Components/Content.razor index e4b51fa..c0fd16c 100644 --- a/Components/Content.razor +++ b/Components/Content.razor @@ -3,7 +3,7 @@
+ style="background-image:linear-gradient(to left, var(--color-base-100), transparent), url('@(Message.User.BackgroundUrl)');"> @Message.User.UserName @@ -32,8 +32,8 @@ - - @Message.CreatedAt.GetPassedTime(Localizer._pLocalizer) + + @Message.CreatedAt.GetPassedTime(Localizer)