ContextWindow: Use EnsureContextRenewed() correctly

This commit is contained in:
2026-03-16 22:58:04 +01:00
parent 0aefab5d63
commit cc018ded10
6 changed files with 12 additions and 22 deletions

View File

@@ -287,8 +287,7 @@ namespace Elwig.Windows {
LockInputs();
UnlockSearchInputs();
FinishInputFilling();
await RefreshList();
RefreshInputs();
await EnsureContextRenewed();
Mouse.OverrideCursor = null;
ViewModel.SearchQuery = "";
ControlUtils.SelectItem(AreaCommitmentList, AreaCommitmentList.ItemsSource.Cast<AreaCom>().Where(a => a.FbNr == fbnr).FirstOrDefault());

View File

@@ -13,7 +13,7 @@ namespace Elwig.Windows {
set {
_lockContext = value;
if (!_lockContext && _renewPending) {
Dispatcher.BeginInvoke(async () => await RenewContext());
Dispatcher.BeginInvoke(async () => await EnsureContextRenewed());
}
}
}
@@ -36,7 +36,7 @@ namespace Elwig.Windows {
public async Task HintContextChange() {
_renewPending = true;
if (LockContext) return;
await RenewContext();
await EnsureContextRenewed();
}
protected async void OnLoaded(object? sender, RoutedEventArgs? evt) {
@@ -44,7 +44,7 @@ namespace Elwig.Windows {
await OnRenewContext(ctx);
}
protected async Task RenewContext() {
protected async Task EnsureContextRenewed() {
if (!_renewPending) return;
using var ctx = new AppDbContext();
await OnRenewContext(ctx);

View File

@@ -812,13 +812,11 @@ namespace Elwig.Windows {
}
EmptyScale();
await RefreshList();
await RefreshDeliveryParts();
await EnsureContextRenewed();
Mouse.OverrideCursor = null;
ControlUtils.SelectItem(DeliveryList, p?.Delivery);
DeliveryPartList.SelectedItem = null;
DeliveryPartList.ScrollIntoView(DeliveryPartList.ItemsSource.Cast<object>().Last());
RefreshInputs();
InitialInputs();
}
@@ -851,8 +849,7 @@ namespace Elwig.Windows {
}
EmptyScale();
await RefreshList();
await RefreshDeliveryParts();
await EnsureContextRenewed();
if (p?.Delivery != null) {
try {
using var ctx = new AppDbContext();
@@ -870,8 +867,7 @@ namespace Elwig.Windows {
Mouse.OverrideCursor = null;
DeliveryList.SelectedItem = null;
await RenewContext();
RefreshInputs();
await EnsureContextRenewed();
InitInputs();
}
@@ -902,7 +898,7 @@ namespace Elwig.Windows {
DisableWeighingButtons();
HideFinishNewPartDeliveryCancelButtons();
ShowNewEditDeleteButtons();
await RenewContext();
await EnsureContextRenewed();
RefreshInputs();
ClearInputStates();
LockInputs();
@@ -1082,9 +1078,7 @@ namespace Elwig.Windows {
LockInputs();
UnlockSearchInputs();
FinishInputFilling();
await RefreshList();
await RefreshDeliveryParts();
RefreshInputs();
await EnsureContextRenewed();
Mouse.OverrideCursor = null;
DepreciateButton.IsEnabled = true;

View File

@@ -374,8 +374,7 @@ namespace Elwig.Windows {
LockInputs();
ViewModel.EnableSearchInputs = true;
FinishInputFilling();
await RefreshList();
RefreshInputs();
await EnsureContextRenewed();
ViewModel.SearchQuery = "";
ControlUtils.SelectItemWithPk(DeliveryScheduleList, year, dsnr);
if (sortid != null)

View File

@@ -225,8 +225,7 @@ namespace Elwig.Windows {
LockInputs();
ViewModel.EnableSearchInputs = true;
FinishInputFilling();
await RefreshList();
RefreshInputs();
await EnsureContextRenewed();
ViewModel.SearchQuery = "";
}

View File

@@ -436,8 +436,7 @@ namespace Elwig.Windows {
UpdateContactInfoVisibility();
ViewModel.EnableSearchInputs = true;
FinishInputFilling();
await RefreshList();
RefreshInputs();
await EnsureContextRenewed();
ViewModel.SearchQuery = "";
Mouse.OverrideCursor = null;
if (mgnr is int m)