Files
MilkyShots/MilkStream.Client/Components/SettingBoxes/SettingBox.razor
REDCODE 9d9491253b refactor: clean up imports, simplify checks, and add SearchDropdown component
- Remove unused using directives across C# and Razor files
- Remove unused IServiceProvider from SettingsRepository
- Simplify null/empty string checks in StatsRepository
- Add null-safe navigation for Albums/Tags in stats queries
- Initialize Asset.Hash default to prevent null refs
- Deduplicate AssetIds in AssetPicker
- Add OnStartedWaiting/OnFinishedWaiting/OnProgressChanged to Job
- Add global SearchDropdown component with keyboard nav
- Fix XML doc param mismatches
2026-07-12 20:47:24 +02:00

38 lines
1.0 KiB
Plaintext

@using Butter.Dtos.Settings
@inject SettingsService SettingsService
@inject IJSRuntime JSRuntime
@code {
[Parameter]
public required SettingDto? Setting { get; set; }
private CancellationTokenSource? _debounceCts;
protected virtual SettingDto? GetSetting() {
return Setting;
}
protected async Task OnValueChanged() {
_debounceCts?.Cancel();
_debounceCts = new CancellationTokenSource();
var token = _debounceCts.Token;
try {
await Task.Delay(500, token);
token.ThrowIfCancellationRequested();
var setting = GetSetting();
if (setting == null) return;
await JSRuntime.InvokeVoidAsync("showToast", "Saving\u2026", "text-bg-secondary");
await SettingsService.UpdateSettingAsync(setting);
await JSRuntime.InvokeVoidAsync("showToast", "Saved", "text-bg-success");
} catch (OperationCanceledException) {
// Debounce cancelled by another change
}
}
}