-
Notifications
You must be signed in to change notification settings - Fork 156
Conversation
Current progress is:
|
Hi, Thanks again for your contribution. I think you should have a look at this for a better desktop integration on windows and osx. In my opinion, recent docs history should not be stored in config.json for privacy reasons. Maybe not even in the config dir. What do you think about using
Maybe because of interferences between main and renderer processes (each of them are reading/writing in the config). Have you tried to call |
I have troubles having a "recent files" menu that is dynamically filled and updated. This may be related to an Electron bug/limitation (electron/electron#528)... I found that I can:
But, the I also tried to pre-create the menu items and then change their labels when the recent files list has changed. But it didn't work out: labels do not change. |
…after closing empty window
app/abr-menu.js
Outdated
|
||
openRecentDoc: function (recentFile) { | ||
this.abrWin.abrApp.open(recentFile); | ||
// FIXCC recent-docs: Recent doc list is not updated after re-opening a recent file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining FIX/TODO: update recent doc list when reopening a recent file.
I this PR ready for a review? I must confess that I lost track, all those updates confused me a bit 😕 |
Yes, this PR is quite large... In my opinion, there are two small things that could be fixed, even though they may be not essential:
But there is one thing that annoys me more: it is that I introduced a menu whose items change over time. This seems to go against Electron possibilities, and I was forced to use undocumented APIs (see my comment above). For fear of instability, one alternative would be to limit this feature to simple OS integration. As the doc says, it works on Windows (confirmed on Windows 10) and Mac (I cannot test this). On Ubuntu 16, there is no menu for selecting a recent doc from the taskbar, but the recent doc is listed in the global "recent files" menu, so it quite works... So there is one decision to make: keep this PR "as is", or trash most of its lines of code to keep what is sure to work in the long term. That's a hard decision to make, and I may not be really objective ;-) So, tell me what you think! |
VS Code has an "Open Recent" sub-menu which is similar to what you did. I think this is a must-have, even though OS integration could be a nice addition. |
First of all: thank you for this contribution. Well, in my opinion we should only use OS integration and avoid the "open recent" menu for several reasons:
Actually OS recent documents is easier to manage for us and it respects user's privacy settings. I personally don't like recent docs recording and I'm glad when I can switch it off with a single setting, which is the case in most OS. So my idea would be to simply use OS integration right now and to wait for a better support of recent docs in Electron (or for some community module which would do the job in a reliable way) to create a dedicated menu. But this is just my opinion, and as I told I don't use this feature. If you really think a menu would be useful then let's add it. I have to say that in such case we will have to work a bit more on it because I don't really agree with some parts of your code. |
To me, the best argument for not doing this is that Electron does not officially support this yet. In my point of view, a "recent docs" menu is an interesting feature: OS integration is usually not enough for me (but I wouldn't say it is a "must-have"). Your privacy concerns are understandable, and an option for enabling/disabling the menu could be useful. And the "clear" menu item can do the rest. The option is also a way of avoiding any bugs on OSX, waiting for someone to test and contribute any patch that is needed. As pointed by @darahak, we could look deeper into VSCode's way of doing this (in fact, I should have done this at first...). That being said, if you still don't feel like merging this PR, it's OK with me. It won't hurt me or discourage my contributing to this project :-) |
OK, it's useful so let's do it!
Currently I see 2 ways to do this in electron:
I need to review this PR first. I'm busy in this time so it'll wait a bit 😕 Then we'll run tests on Windows/OSX/Linux. I got a VM for each OS now so I could maybe help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took an some time to read your code and I dropped my comments about it.
My main observation is that using the localStorage API to store filepaths actually leads to several issues. For instance this won't work if there is no open window because localStorage is a browser-specific API. Therefor clear() won't work in some cases on OSX.
I'm really sorry because I'm the one who suggested to use localStorage, but obviously we should have thought more about this at the beginning 😕
I still think that config.json is not the good place to store recent paths, but maybe we could use another file, let's say recent.json, in the same directory. This way the code would also be easier to read because most operations (such as writting/reading JSON and updating/clearing menu) would be done in the main process while abrDocument methods would only trigger calls to abrApplication.
What do you think?
app/abr-application.js
Outdated
if (recentPaths) { | ||
if (recentPaths.length > 0) { | ||
// May not work on all OS'es (electron doc says Windows and MacOS are OK, tests on Ubuntu 16 show it is OK too) | ||
// See: https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#recent-documents-windows--macos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to document this here.
app/abr-application.js
Outdated
// 1. Start Abricotine ==> Opens a new empty window | ||
// 2. Open one of the recent files using the "File > Recent" menu ==> Selected doc is opened in a new window (unlike the "File > Open menu") | ||
// 3. Close the empty window (the one opened when Abricotine started) | ||
// 4. Return the window opened at step 2, open a file using the "File > Open" menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is useless, code is clear enough.
app/abr-application.js
Outdated
}, | ||
|
||
clearRecentDocs: function(abrWin) { | ||
// See: https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#recent-documents-windows--macos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here. We won't add links to electron documentation for each method we use.
app/renderer/abr-document.js
Outdated
@@ -19,9 +19,11 @@ var remote = require("electron").remote, | |||
shell = require("electron").shell, | |||
spellchecker = require('spellchecker'); | |||
|
|||
function AbrDocument () { | |||
function AbrDocument (theLocalStorage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This theLocalStorage argument is totally confusing. Why don't you simply use localStorage ?
default/config.json
Outdated
@@ -8,7 +8,8 @@ | |||
}, | |||
"autopreview-security": true, | |||
"editor": { | |||
"font-size": "16px" | |||
"font-size": "16px", | |||
"max-recent": 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max-recent
should not be stored under editor
.
editor
contains the text editor control basic configuration.
app/renderer/abr-document.js
Outdated
updateRecentPath: function (path) { | ||
var thisDoc = this; | ||
|
||
this.getConfig(undefined, function(theConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct way to do is:
this.getConfig("editor:max-recent", function(max) {
app/renderer/abr-document.js
Outdated
clearRecentDocs: function() { | ||
var thisDoc = this; | ||
|
||
this.getConfig(undefined, function(theConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to get the config here.
That's OK with me. Your "small" change requests have been fixed, I still need to work on the "storage". I'll keep you posted. |
app/renderer/main.js
Outdated
@@ -7,6 +7,6 @@ | |||
var AbrDocument = require.main.require("./abr-document.js"); | |||
|
|||
$( function () { | |||
var abrDoc = new AbrDocument(); | |||
var abrDoc = new AbrDocument(localStorage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! Don't forget this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed that one... Fixed.
Is this merge request still in work, or is it blocked some other issue? |
@nettnikl This PR had no activity for almost 4 years and the related branch is 335 commits behind the current develop branch, so we can consider it obsolete unfortunately. I'm closing this thread. |
Fix for #69.
What's to be done: