Skip to content

Feature: Show confirmation dialog when the undo operation is to delete items. #11185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 7, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ public async Task<ReturnResult> TryUndo()
{
return ReturnResult.InProgress;
}
bool keepHistory = false;
try
{
return await operations.Undo(App.HistoryWrapper.GetCurrentHistory());
ReturnResult result = await operations.Undo(App.HistoryWrapper.GetCurrentHistory());
keepHistory = result is ReturnResult.Cancelled;
return result;
}
finally
{
App.HistoryWrapper.DecreaseIndex();
if (!keepHistory)
App.HistoryWrapper.DecreaseIndex();

semaphore.Release();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public async Task<ReturnResult> Undo(IStorageHistory history)
case FileOperationType.CreateNew: // Opposite: Delete created items
if (!IsHistoryNull(history.Source))
{
return await helpers.DeleteItemsAsync(history.Source, false, true, false);
return await helpers.DeleteItemsAsync(history.Source, true, true, false); // Show a dialog to prevent unexpected deletion
}
break;
case FileOperationType.CreateLink: // Opposite: Delete created items
if (!IsHistoryNull(history.Destination))
{
return await helpers.DeleteItemsAsync(history.Destination, false, true, false);
return await helpers.DeleteItemsAsync(history.Destination, true, true, false); // Show a dialog to prevent unexpected deletion
}
break;
case FileOperationType.Rename: // Opposite: Restore original item names
Expand All @@ -61,7 +61,7 @@ public async Task<ReturnResult> Undo(IStorageHistory history)
case FileOperationType.Copy: // Opposite: Delete copied items
if (!IsHistoryNull(history.Destination))
{
return await helpers.DeleteItemsAsync(history.Destination, false, true, false);
return await helpers.DeleteItemsAsync(history.Destination, true, true, false); // Show a dialog to prevent unexpected deletion
}
break;
case FileOperationType.Move: // Opposite: Move the items to original directory
Expand Down