refactor(editor): the open sequence's jobs in their own type; restore undo as an object
WIP of the interrupted fix stage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
9 files changed
+356
-42
No files matched your search
@@ -563,31 +563,30 @@ public sealed class ExportTab : EditorTab
|
||||
private async Task RestoreAsync()
|
||||
{
|
||||
if (SelectedCopy is not { } copy) return;
|
||||
var session = Editor.Session;
|
||||
var before = session.Project;
|
||||
ProjectRestore? restore;
|
||||
try
|
||||
{
|
||||
if (!await session.RestoreAsync(copy))
|
||||
{
|
||||
Editor.Shell.Notify(Loc.L("Editor.Copy.Same"), copy.Label);
|
||||
return;
|
||||
}
|
||||
restore = await Editor.Session.RestoreAsync(copy);
|
||||
}
|
||||
catch (InvalidDataException ex)
|
||||
{
|
||||
Editor.Shell.ReportError(ex);
|
||||
return;
|
||||
}
|
||||
var restored = session.Project;
|
||||
if (restore is null)
|
||||
{
|
||||
Editor.Shell.Notify(Loc.L("Editor.Copy.Same"), copy.Label);
|
||||
return;
|
||||
}
|
||||
var editor = Editor;
|
||||
bool Undoable() => ReferenceEquals(editor.Shell.Sequence.Editor, editor) && ReferenceEquals(session.Project, restored);
|
||||
editor.Shell.ShowToast(new Toast
|
||||
{
|
||||
Title = Loc.L("Editor.Copy.Restored"),
|
||||
Message = copy.Label,
|
||||
ActionText = Loc.L("Editor.Copy.Undo"),
|
||||
ActionToolTip = Loc.L("Tooltips.Editor.Copy.Undo"),
|
||||
ActionCommand = new RelayCommand(() => session.Edit(_ => before), Undoable),
|
||||
// Only in the editor that made it: another sequence opened meanwhile has its own project.
|
||||
ActionCommand = new RelayCommand(() => restore.Undo(), () => ReferenceEquals(editor.Shell.Sequence.Editor, editor) && restore.CanUndo),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user