Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Avoid serializing Function in array template #13432

Merged
merged 1 commit into from
Mar 14, 2018
Merged

Conversation

darkdh
Copy link
Member

@darkdh darkdh commented Mar 13, 2018

fix #13421
fix #11576

Auditors: @bridiver

Test Plan:

  1. Set sessionSaveInterval to 1 in js/constants/appConfig.js
  2. Playing around with bookmark toolbar folder
  3. Playing around with auotfill menu(fill with entry and clear)
  4. Playing around with hamburger menu
  5. Playing around with back/forward long pressed menu
  6. There shouldn't be any exceptions about "function can be cloned"

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed. (Ask a Brave employee to help if you cannot access this document.)

Test Plan:

Reviewer Checklist:

  • Request a security/privacy review as needed if one was not already requested.

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@darkdh darkdh added this to the 0.21.x w/ Chromium 65 (Beta Channel) milestone Mar 13, 2018
@darkdh darkdh self-assigned this Mar 13, 2018
@darkdh darkdh requested a review from bridiver March 13, 2018 18:40
docs/state.md Outdated
}],
top: number // the top position of the context menu
},
contextMenuDetail: string, // uuid for triggering state update
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the docs here with a note explaining the hack

*/
setContextMenuDetail: function (detail) {
const Immutable = require('immutable')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please leave a comment explaining why we did this

@@ -641,7 +648,7 @@ const doAction = (action) => {
break
case windowConstants.WINDOW_TOGGLE_MENUBAR_VISIBLE:
if (getSetting(settings.AUTO_HIDE_MENU)) {
doAction({actionType: windowConstants.WINDOW_SET_CONTEXT_MENU_DETAIL})
windowState = contextMenuState.setContextMenu(windowState)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is some weird reason why these call the action instead of just setting state. To be safe I think we shouldn't change it unless we have to

@@ -215,7 +218,7 @@ class ContextMenu extends React.Component {
const currentWindow = state.get('currentWindow')
const activeFrame = frameStateUtil.getActiveFrame(currentWindow) || Immutable.Map()
const selectedIndex = currentWindow.getIn(['ui', 'contextMenu', 'selectedIndex'], null)
const contextMenuDetail = currentWindow.get('contextMenuDetail', Immutable.Map())
const contextMenuDetail = contextMenuState.getContextMenu()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should still pass in the state even though we aren't using it. That will simplify things if we fix the real issue later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea is to hide the hack from everything except the action dispatch

getContextMenu: (windowState) => {
windowState = validateState(windowState)
return windowState.get('contextMenuDetail', Immutable.Map())
getContextMenu: () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see note below

if (windowState.getIn(['contextMenuDetail', 'type']) === 'hamburgerMenu') {
windowState = windowState.set('hamburgerMenuWasOpen', true)
if (contextMenuDetail.get('type') === 'hamburgerMenu') {
hamburgerMenuWasOpen = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could leave this in the state since it's just true/false

@codecov-io
Copy link

codecov-io commented Mar 13, 2018

Codecov Report

Merging #13432 into 0.21.x-C65 will decrease coverage by 0.01%.
The diff coverage is 7.4%.

@@              Coverage Diff               @@
##           0.21.x-C65   #13432      +/-   ##
==============================================
- Coverage        57.1%   57.08%   -0.02%     
==============================================
  Files             280      280              
  Lines           27495    27507      +12     
  Branches         4470     4471       +1     
==============================================
+ Hits            15700    15702       +2     
- Misses          11795    11805      +10
Flag Coverage Δ
#unittest 57.08% <7.4%> (-0.02%) ⬇️
Impacted Files Coverage Δ
js/actions/windowActions.js 4.95% <0%> (-0.11%) ⬇️
js/stores/windowStore.js 27.63% <0%> (-0.17%) ⬇️
app/common/state/contextMenuState.js 39.02% <28.57%> (+1.18%) ⬆️

fix #13421
fix #11576

Auditors: @bridiver

Test Plan:
1. Set `sessionSaveInterval` to `1` in js/constants/appConfig.js
2. Playing around with bookmark toolbar folder
3. Playing around with auotfill menu(fill with entry and clear)
4. Playing around with hamburger menu
5. Playing around with back/forward long pressed menu
6. There shouldn't be any exceptions about "function can be cloned"
@darkdh
Copy link
Member Author

darkdh commented Mar 13, 2018

addressed all the comments

@bsclifton bsclifton self-requested a review March 13, 2018 21:47
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look great! Could definitely use some unit tests- but since there weren't any, I think it's good for now 😄

@bsclifton bsclifton merged commit 8f86a6f into 0.21.x-C65 Mar 14, 2018
@bsclifton bsclifton deleted the issue-13421 branch March 14, 2018 05:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants