Skip to content
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

Be smarter about remembering which files you were working on after an app restart #54

Closed
simonw opened this issue Sep 4, 2021 · 11 comments
Labels
electron-wrapper Features that go in the Node.js/Electron code research usability

Comments

@simonw
Copy link
Owner

simonw commented Sep 4, 2021

Original title: Integrate with recent files menu

The recent files menu shows up when you right click on the Dock icon, and can also integrate with e.g. the history menu. When a file from that list is selected the open-file event is sent to the application.

@simonw simonw added electron-wrapper Features that go in the Node.js/Electron code research labels Sep 4, 2021
@simonw
Copy link
Owner Author

simonw commented Sep 4, 2021

Two parts to this: first, add app.addRecentDocument(filepath); to the code that opens files, e.g. these two bits:

datasette-app/main.js

Lines 299 to 301 in 55f63b1

} else {
datasette.openPath(responseJson.path);
}

datasette-app/main.js

Lines 331 to 333 in 55f63b1

} else {
pathToOpen = responseJson.path;
}

The harder part is to add handling for the open-file event - this needs to be at the base level of the module:

app.on("open-file", function (event, filepath) {
  console.log(event, filepath);
});

@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

https://twitter.com/webology/status/1435471527688953857

Some type of recently opened databases/files list would be nice too. I closed/re-opened (which is almost instant btw) and I understand what temporary means, but I kind of expected a list of recently open databases.

@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

This is about more than just the "recent files" feature - a general usability problem right now is that it's very easy to quit the app and come back again and have to rebuild state from scratch. Need to do better than that!

@jefftriplett
Copy link

Because Twitter, I started a new database. When I re-opened it, I expected to see it in the list where "temporary" database is, but I had to search for it. I think this was in the same folder as my CSV file, but I'd have to double-check it.

@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

Related: #42 - "If you open a CSV and then install a plugin the CSV table vanishes"

@simonw simonw added this to the 0.2 - plugins and progress bars milestone Sep 8, 2021
@simonw simonw changed the title Integrate with recent files menu Be smarter about remembering which files you were working on after an app restart Sep 8, 2021
@mnckapilan
Copy link
Contributor

I'm a novice trying to get some progress on this issue – and would love some advice – what would be the idiomatic way to persist user-specific details (like a list of recent files) within the Electron app?

Right now the most similar functionality I notice is the list of plugins installed, but that's stored and is queried from DatasetteServer itself – or would we want to persist it at the Electron-level using something like this rather than the python level?

@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

@mnckapilan I'm planning to more-or-less implement https://www.electronjs.org/docs/tutorial/recent-documents - which ties into the operating system's own concept of "recently opened files". I may go a step further than that though, perhaps having the default index page of the app also display that list to help people get back to what they were doing?

@mnckapilan
Copy link
Contributor

I've made a primitive attempt at addressing this (for recently opened CSVs), though some refactoring is likely necessary to extend this to recent databases and newly created databases.

This is my very first attempt at contributing to open-source, so I do apologise if I'm missed something along the way!

@mnckapilan
Copy link
Contributor

Was looking around for patterns on how different applications deal with recently opened items. VSCode takes an approach of separating their 2 recent types – individual files and folders – and also gives the option of reopening closed workspace.

Screenshot 2021-09-08 at 10 34 46 pm

Something similar could be implemented for distinguishing between recently opened CSVs and databases.

I've added a file menu option for recently opened CSVs to the #77, yet to extend it to databases.

@simonw
Copy link
Owner Author

simonw commented Sep 10, 2021

I'm going to include part of the list of recent files on the homepage redesign in #91.

@simonw simonw closed this as completed Sep 10, 2021
@simonw
Copy link
Owner Author

simonw commented Sep 13, 2021

I'm going to include part of the list of recent files on the homepage redesign in #91.

Turns out I couldn't find a way to gain access to that list of recent files in a way that would let me feature them in the hompage, so I left them in the "File -> Open Recent" sub-menu instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron-wrapper Features that go in the Node.js/Electron code research usability
Projects
None yet
Development

No branches or pull requests

3 participants