Ensured, that last minute changes are written to disk

This commit is contained in:
tsommer committed 2022-09-21 17:33:03 +02:00
1 parent 97f3226d17
commit 24a7093674
3 files changed
+36 -6

No files matched your search

@@ -50,12 +50,6 @@ public sealed partial class Translation : UserControl
}
}
private async void SaveChanges(object? sender, ElapsedEventArgs e)
{
if (this.currentTranslationId > -1)
await TranslationProcessor.SaveChangedTranslation(this.currentTranslationId, this.textBox.Text);
}
public async Task Configure(DataModel.Database.Translation translation)
{
this.isLoading = true;
@@ -78,5 +72,16 @@ public sealed partial class Translation : UserControl
this.saveTimer.Stop();
this.saveTimer.Start();
if(this.ParentForm is UI_WinForms.Main main)
main.AddDeferredSaveOperation(this.currentTranslationId, () => this.SaveChanges(null, null));
}
private async void SaveChanges(object? sender, ElapsedEventArgs e)
{
if (this.currentTranslationId > -1)
await TranslationProcessor.SaveChangedTranslation(this.currentTranslationId, this.textBox.Text);
if(this.ParentForm is UI_WinForms.Main main)
main.RemoveDeferredSaveOperation(this.currentTranslationId);
}
}