This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 972
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Remove ref dependency from Frame
- Loading branch information
Showing
16 changed files
with
505 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const assert = require('assert') | ||
const { makeImmutable, isMap } = require('./immutableUtil') | ||
|
||
const validateState = function (state) { | ||
state = makeImmutable(state) | ||
assert.ok(isMap(state), 'state must be an Immutable.Map') | ||
return state | ||
} | ||
|
||
const contextMenuState = { | ||
setContextMenu: (state, detail) => { | ||
detail = makeImmutable(detail) | ||
state = validateState(state) | ||
|
||
if (!detail) { | ||
if (state.getIn(['contextMenuDetail', 'type']) === 'hamburgerMenu') { | ||
state = state.set('hamburgerMenuWasOpen', true) | ||
} else { | ||
state = state.set('hamburgerMenuWasOpen', false) | ||
} | ||
state = state.delete('contextMenuDetail') | ||
} else { | ||
if (!(detail.get('type') === 'hamburgerMenu' && state.get('hamburgerMenuWasOpen'))) { | ||
state = state.set('contextMenuDetail', detail) | ||
} | ||
state = state.set('hamburgerMenuWasOpen', false) | ||
} | ||
|
||
return state | ||
} | ||
} | ||
|
||
module.exports = contextMenuState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.