-
Notifications
You must be signed in to change notification settings - Fork 973
Ensuring File > Share context menu items are disabled when no windows are open #13933
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13933 +/- ##
==========================================
- Coverage 56.46% 56.45% -0.01%
==========================================
Files 284 284
Lines 29340 29362 +22
Branches 4872 4877 +5
==========================================
+ Hits 16566 16577 +11
- Misses 12774 12785 +11
|
6ea81a1
to
2500c2f
Compare
app/browser/menu.js
Outdated
case appConstants.APP_WINDOW_CREATED: | ||
{ | ||
const windowCount = BrowserWindow.getAllWindows().filter((w) => w.isFocused()).length | ||
if (action.actionType === 'app-window-closed' && windowCount === 0) { |
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.
could you use the constant name here instead?
if (action.actionType === appConstants.APP_WINDOW_CLOSED && windowCount === 0) {
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.
comments left- otherwise, works and looks great! 😄 👍
app/browser/menu.js
Outdated
const windowCount = BrowserWindow.getAllWindows().filter((w) => w.isFocused()).length | ||
if (action.actionType === 'app-window-closed' && windowCount === 0) { | ||
updateShareMenuItems(state, false) | ||
} else if (action.actionType === 'app-window-created' && windowCount === 1) { |
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 as above comment
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.
Changes requested to make sure we are using window API that considers tabbed browser windows instead of any muon/electron window
app/browser/menu.js
Outdated
case appConstants.APP_WINDOW_CLOSED: | ||
case appConstants.APP_WINDOW_CREATED: | ||
{ | ||
const windowCount = BrowserWindow.getAllWindows().filter((w) => w.isFocused()).length |
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.
Please don't use the muon BrowserWindow
API raw. Instead please use the app/browser/windows.js
API, specifically getAllRendererWindows
or getActiveWindow
. The former should be enough as it makes sure the hidden window isn't included.
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 call- I was wondering that myself 😄
eacab52
to
99cba57
Compare
Changes pushed cc: @bsclifton @petemill |
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.
Works great! Updated changes look good too
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.
Works nicely 👍 . Just left a comment about the neccessity of excludeShareSites
rather that just removing the digg entry as I don't think it's being used anywhere else. Worth another search in order to reduce the complexity. 🔍
app/browser/share.js
Outdated
@@ -19,6 +19,11 @@ const templateUrls = { | |||
reddit: 'https://reddit.com/submit?url={url}&title={title}' | |||
} | |||
|
|||
// Sites that are not currently in the File > Share context menu | |||
const excludedShareSites = [ |
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.
Do we need this rather than just remove the digg item from templateUrls
. From a quick search I could not find any other usage of the templateUrls
export from share.js.
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.
@petemill good thought, I did a search and it looks fine to remove. I've pushed an update removing the excludedShareSites
addition. I left removing Digg from templateUrls
a separate commit for ease of search should we want to add it back at any point.
Refactoring menu.js item attribute functions
1c40501
to
f371e51
Compare
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.
LGTM, thanks for the additional fixes and cleanup 🥇
Ensuring File > Share context menu items are disabled when no windows are open
Ensuring File > Share context menu items are disabled when no windows are open
Fixes #13928
This PR also includes some refactoring for the menu code concerning setting the
checked
status of a menu item. The functions are now generalized to setting a given attribute, so thatenabled
can be toggled as well.Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
Tests