mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 03:19:56 +00:00
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:
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)
|
||||
|
||||
Reference in new issue
Block a user