Scripting - Add confirm dialog when discarding changes

Editor - Fix missing repeat mode button
Editor - Auto-save 1 sec after last change
General UI - Fix main window drag handle
This commit is contained in:
Robert committed 2022-07-16 10:42:20 +02:00
1 parent e3907e6a76
commit 311bdee8da
13 files changed
+103 -25

No files matched your search

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Threading.Tasks;
@@ -64,6 +65,19 @@ internal class ProfileEditorService : IProfileEditorService
PixelsPerSecond = _pixelsPerSecondSubject.AsObservable();
Tools = tools;
SelectedKeyframes = selectedKeyframes;
// Observe executing, undoing and redoing commands and run the auto-save after 1 second
History.Select(h => h?.Execute ?? Observable.Never<Unit>())
.Switch()
.Merge(History.Select(h => h?.Undo ?? Observable.Never<IProfileEditorCommand?>())
.Switch()
.Select(_ => Unit.Default))
.Merge(History.Select(h => h?.Redo ?? Observable.Never<IProfileEditorCommand?>())
.Switch()
.Select(_ => Unit.Default))
.Throttle(TimeSpan.FromSeconds(1))
.SelectMany(async _ => await AutoSaveProfileAsync())
.Subscribe();
}
public IObservable<ProfileConfiguration?> ProfileConfiguration { get; }
@@ -425,6 +439,22 @@ internal class ProfileEditorService : IProfileEditorService
return newHistory;
}
private async Task<Unit> AutoSaveProfileAsync()
{
try
{
await SaveProfileAsync();
}
catch (Exception e)
{
_windowService.ShowExceptionDialog("Failed to auto-save profile", e);
_logger.Error(e, "Failed to auto-save profile");
throw;
}
return Unit.Default;
}
private void Tick(TimeSpan time)
{
if (_profileConfigurationSubject.Value?.Profile == null || _suspendedEditingSubject.Value)