Repository metrics
- Stars
- (3,248 stars)
- PR merge metrics
- (PR metrics pending)
Description
Summary When a project is deleted from disk, it will be silently removed from Guppy.
In many cases, this behaviour is fine; if the user deletes it with Finder/Explorer, it should naturally also disappear from Guppy. But given that this app is targeted at beginners, it might be good to throw a notice prompt up:
Project deleted
Your projects Thing 1, Thing 2, and Thing 3 were deleted from disk, and have been removed from Guppy.
Implementation
The code that manages this is in read-from-disk.service, under loadGuppyProjects:
Right now we're silently swallowing these errors.
We could throw a prompt right there in the .catch, but that would mean 1 prompt for every deleted project. If the user deletes 10 projects, that's a lot of prompts!
Instead, we want to bubble those errors in with the results. So if we're loading 5 projects and 2 were deleted, the value passed to results might look like this:
[ project1Json, Error, Error, project4Json, project5Json]
We should split loadGuppyProjects up into a couple functions; one to parse the disk and return results, and then another to build a valid projects object out of it.
Here's the flow I imagine, in refresh-projects.saga.js:
const pathsArray = yield select(getPathsArray);
const projectsFromDisk = yield call(loadGuppyProjects, pathsArray);
// This will now be that array of mixed JSON and errors
const deletedPaths = /* some method that finds the paths in `pathsArray` that produced errors */
if (deletedPaths.length > 0) {
const deletedProjectNames = /* some method that converts deletedPaths to projectNames */
const message = /* some method to build up a nice error message, taking into account the number of projects for proper grammar */
dialog.showMessageBox({...});
}
As a bonus, this would set us up well to handle other types of errors when loading projects.