Repository navigation
feat(home): undo a conversion, its results go to the Recycle Bin / Trash (#553) - #564
cre8ive-marketing wants to merge 4 commits into
Conversation
…nifeLemon#553) A recent conversion gets an Undo button while every result is still as the job left it (same size and write time, saved in history.json). Undo moves the results to the Recycle Bin / Trash and the card says so. With "Replace the original" it also says the originals are there; they stay (KnifeLemon#332 unchanged). A source left as it was ("Only if smaller") is never treated as a result.
|
@KnifeLemon, CI is green on every check here. When you have reviewed it, could you merge it into main? |
KnifeLemon
left a comment
There was a problem hiding this comment.
Thanks @cre8ive-marketing, this is option a as agreed: Undo only goes through the existing MoveToTrash, which never deletes for good. The size-and-time stamp keeps it away from files that changed. The "Only if smaller" + "Replace the original" case, where the result is the user's own file, is handled and tested. Old history.json entries load and simply have nothing to undo.
- A partly done Undo gets stuck.
HomePageViewModel.cs:138checksUnchanged()and moves file by file. If the second result changed, or the Trash refuses it ("in use"), the first is already in the Trash and the entry isn't marked. After the nextHistoryChangedthe card is rebuilt, and line 61 requires every result to still exist, soCanUndois false: half the results are in the Trash, with no Undo button and no "Undone" text. Please check every result before moving any, record which ones were moved (e.g. aTrashedflag onHistoryOutput, saved even when a later one is refused), and baseCanUndoon the results not yet moved. - Undo runs on the UI thread. On Windows,
RecycleBin.Movestarts and joins an STA thread for each file, so a job with hundreds of results ("Save every frame", PDF pages) freezes the window until it's done. Please make it an async command that moves the files off the UI thread, with the button disabled meanwhile. - Pandoc's picture folder is left behind. Pandoc writes a document's pictures into
<name>_filesnext to it (JobQueue.cs:974-975), and that folder isn't inOutputs, so Undo moves the .md/.html to the Trash and leaves its pictures. Either move that folder too, if it's still there, or give such jobs no Undo, as you did for Extract. - Optional:
Undoablerepeats every pathOutputsalready holds. For a frame-sequence job that's thousands of extra lines inhistory.jsonper entry; no Undo above a few hundred results would keep it small.
…UI thread From the review of KnifeLemon#564: - Every result is checked before any moves; a changed one stops Undo with nothing moved. - Each result moved is saved as Trashed, also when the Trash then refuses a later one, so the card keeps offering Undo for the rest instead of getting stuck. - The files move on a background thread; the button is disabled meanwhile. - A document whose pictures Pandoc wrote into "<name>_files" gets no Undo, rather than leaving the pictures behind. - More than 500 results get no Undo, so history.json stays small.
|
@KnifeLemon, thanks for the review. All four points are in, pushed as 32efd75 and 363daea, with main merged in:
German strings for the new keys are included, since #541 came in on main. Full |
|
@KnifeLemon, CI is green on every check after the review fixes. Could you take another look and merge it into main if it is good? |
Part 2 of #553 (option a, as approved).
What it does
A recent conversion on Home gets an Undo button. Undo moves that job's results to the Recycle Bin / Trash, and the card then says "Undone: the results are in the Recycle Bin / Trash".
HistoryEntry.Undoablekeeps each result's path, size and last write time. The button shows only while every one still matches, so a file edited since, or overwritten by another conversion, is never moved.FileResult.OriginalInTrashrecords whether the original really went to the Trash, and a source that didn't is never listed as a result.history.json, no settings change.New strings (
home.undo,home.undo_hint,home.undone,home.undone_original,home.undo_failed,trash.changed) are in all 16 languages. One new icon,Icon.Undo(Material Design "undo").Tests
HistoryEntryTests: a finished job remembers its results for Undo and they survive a reload; a changed or deleted result no longer matches; an old entry has nothing to undo.ReplaceOriginalTests: a result in the original's place is undoable and says the original is in the Trash; when the Trash refuses, only the result beside it is undoable; "Only if smaller" leaves an unchanged original that Undo must never touch.RecentConversionTests: Undo moves the results, saves the entry as undone, shows the refusal reason, and offers nothing for a result changed since; the Home screenshots now show the button.dotnet format --verify-no-changesis clean.dotnet test: Platform 81, Core 606, CLI 27, Setup 176, Engines 1821 and App 1345 pass, none fail.Closes part of #553 (Fit to a place comes in its own PR).