Electron Fundamentals, v2 Electron Fundamentals, v2

Add a File to Recent Documents

Check out a free preview of the full Electron Fundamentals, v2 course:
The "Add a File to Recent Documents" Lesson is part of the full, Electron Fundamentals, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Steve demonstrates a basic method on how to add the file to recent documents, and briefly discusses the pitfalls of attempting to mimic native applications exactly.

Get Unlimited Access Now

Transcript from the "Add a File to Recent Documents" Lesson

[00:00:00]
>> Steve Kinney: The other thing that we might wanna do is a lot of applications will show you the recent documents, right? My application shows me the recent documents from when I was working on this previously but not officially, right? And so what we want to do is append it to the recent documents there as well.

[00:00:25] And we could do them to render a process, but that is something that kind of belongs in the main processes. The method on app and when we see it, it will be very clear what it does. But we'll say when we open the file, say app., this one looks good.

[00:00:48] addRecentDocument feels like a good method. I could do it on the render process, too. I don't wanna do it on every keystroke, though, which is when that update user interface is getting called to see if we have saved or unsaved changes. And I don't want to use the remote module, so do it here and we'll just say as the filename and now that application will get added.

[00:01:12] So then if you open up a few files and either in Windows, I think you've got the recent documents in Windows Explorer should show up there. In MacOS, it will show up either in the recent documents in the Apple menu or when you right click on the icon and on Linux, I don' know.

[00:01:30] [LAUGH] Somewhere but cool, so yeah, again, we get to basically play nicely as if we were a native application, even though we're built on web technologies. Which is kinda cool and not something I'm used to seeing from the GTK built applications or Java apps or anything along those lines.

[00:01:53] It is definitely, you're not gonna fool anyone. I have a strong opinion about building Electron apps, which is if you try to fool somebody, you're never gonna create a web interface that looks like Mac OS, or Windows, or a thing like that. Slack, and Visual Studio Code, and all those applications, don't really try.

[00:02:10] And that's probably better than trying and by getting 95% of the way there. But you can do some of the kind of like base levels of what a user comes to expect out of an application, really easy with some of the APIs that Electron gives us.