Ported from the owner's b2b.next and adapted from MudBlazor to the daisyUI
components:
- LocalizableComponentBase provides CascadingState, Navigation, Toast,
IsLoading/IsDefaultDisabled, WhenOnline/StartOnlinePolling, and after-render
jobs that actually run.
- CascadingState starts with initialised state and polls the online status
with a PeriodicTimer. It reports errors through ILoggingService plus a toast,
and disposes what it holds.
- New pieces:
- ToastService + ToastHost, the snackbar, with AddResponseError/Success/
Warning/Exception in SUtility;
- ErrorViewer, which shows the validation messages plus AdditionalError(s);
- LoggingService, which writes to the console and the IndexedDB client log.
- HttpService is rebuilt and registered:
- auth levels Get/Post/Delete, *Anon and *TotallyAnon;
- retry with backoff;
- classified failures (FailureCodes) instead of exceptions;
- HTTP 410 on cancel;
- the "default" client.
ReadWebResult and DefaultReadFromJsonAsync read its responses.
- ClientJsonContext is source-generated, and SUtility.DefaultSerializer and
Blazored.LocalStorage use it.
- WebResult gains a C# 14 IsInvalid extension property.
The code follows the imported rules:
- Every service and async helper takes a CancellationToken last.
- Primary constructors replace constructor-plus-fields.
- MessagesService and IStorage return Task<WebResult> / Task<List<T>>.
MessagesService is still mock, building its results in memory; the seed
feed and thread moved to Faker.
- Index and ExpandMessage follow the page pattern: an offline guard with
WhenOnline, LoadData, and early returns with toasts on the results they used
to ignore. ExpandMessage reloads on route change and shows "not found"
instead of a null message.
- Model and state collections are [], and the fake identity defaults moved
out of the models.
- Components:
- no ?. chains over initialised state;
- [Inject] instead of @inject;
- IsDefaultDisabled on the actions;
- autocomplete on every text input;
- Localizer[key, args] instead of string.Format;
- the localizer no longer leaks its inner _pLocalizer.
- Settings → General gains a language picker (English/Italiano), and
SetDefaultCulture limits the culture to those two.
Bugs fixed along the way:
- A compose with untouched (null) content passed the empty check.
- File errors were joined with <br/> and rendered as markup.
- ClientLogs.ErrorMessage() threw on warnings.
- CoalescingStringLocalizer[key, args] showed a raw "{0}" for missing keys.
- AppStatusService exposed a call to a JS function that doesn't exist.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
106 lines
2.9 KiB
Plaintext
106 lines
2.9 KiB
Plaintext
@inherits LocalizableComponentBase
|
|
|
|
<section class="flex flex-col gap-4">
|
|
|
|
@if (isPosting)
|
|
{
|
|
<div class="block p-3 md:p-4 rounded-xl neo-raised neo-xs">
|
|
<MessageUpsertForm OnMessageSubmit="OnMessageSubmit" />
|
|
</div>
|
|
}
|
|
|
|
<div class="flex justify-between gap-3">
|
|
|
|
<EditForm Model="Filters">
|
|
<div class="flex flex-row gap-3">
|
|
@if (OnTimelineChanged.HasDelegate)
|
|
{
|
|
<DSelect TValue="TimelineType" class="w-auto" Value="Filters.TimelineType"
|
|
ValueChanged="async v => await OnTimelineChange(v)" ValueExpression="() => Filters.TimelineType">
|
|
<Prefix>
|
|
<i class="@Filters.TimelineType.GetTimelineTypeIcon()"></i>
|
|
</Prefix>
|
|
<ChildContent>
|
|
@foreach (var timelineType in Enum.GetValues<TimelineType>())
|
|
{
|
|
<option value="@timelineType">@Localizer[timelineType.ToString()]</option>
|
|
}
|
|
</ChildContent>
|
|
</DSelect>
|
|
}
|
|
@if (OnTimeSortingChanged.HasDelegate)
|
|
{
|
|
<DSelect TValue="TimeSortingType" class="w-auto" Value="Filters.TimeSortingType"
|
|
ValueChanged="async v => await OnTimeSortChange(v)" ValueExpression="() => Filters.TimeSortingType">
|
|
<Prefix>
|
|
<i class="ion-md-funnel"></i>
|
|
</Prefix>
|
|
<ChildContent>
|
|
@foreach (var timeSortingType in Enum.GetValues<TimeSortingType>())
|
|
{
|
|
<option value="@timeSortingType">@Localizer[timeSortingType.ToString()]</option>
|
|
}
|
|
</ChildContent>
|
|
</DSelect>
|
|
}
|
|
</div>
|
|
</EditForm>
|
|
|
|
@if (OnMessageSubmit.HasDelegate)
|
|
{
|
|
<div>
|
|
<DButton Active="isPosting" OnClick="OpenCloseMessageForm">
|
|
<i class="ion-md-create"></i>
|
|
<span>@Localizer["Post"]</span>
|
|
</DButton>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<div></div>
|
|
}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
@code {
|
|
[Parameter] public EventCallback<MessageForm> OnMessageSubmit { get; set; }
|
|
[Parameter] public EventCallback<TimelineType> OnTimelineChanged { get; set; }
|
|
[Parameter] public EventCallback<TimeSortingType> OnTimeSortingChanged { get; set; }
|
|
[Inject] ILocalStorageService LocalStorage { get; set; }
|
|
bool isPosting;
|
|
ActionBarFilter Filters { get; set; } = new();
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var filters = await LocalStorage.GetItemAsync<ActionBarFilter>(nameof(ActionBarFilter));
|
|
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;
|
|
await LocalStorage.SetItemAsync(nameof(ActionBarFilter), Filters);
|
|
await OnTimeSortingChanged.InvokeAsync(Filters.TimeSortingType);
|
|
}
|
|
} |