Created
April 7, 2016 03:55
-
-
Save adrianmcli/55caa5a6862021507406ec3ce1ec03e8 to your computer and use it in GitHub Desktop.
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
const hasFocus = editorState.getSelection().getHasFocus(); | |
if (hasFocus) { | |
// make an array of blocks we need to request locks for | |
// 1. which locks do we currently have? | |
const currentLocks = this.locks.map(lock => lock.blockKey); | |
// 2. which locks does the user want? (getSelectedBlocks) | |
const desiredLocks = getSelectedBlocks().map(block => block.getKey()); | |
// 3. Make a list of all elements in the desiredLocks not contained in currentLocks | |
const requestLocks = R.difference(desiredLocks, currentLocks); | |
// 4. Make a list of all elements in currentLocks not contained in desiredLocks | |
const releaseLocks = R.difference(currentLocks, desiredLocks); | |
// 5. send the request for those | |
requestBlockLocks(requestLocks, user); | |
releaseBlockLocks(releaseLocks, user); | |
} else { | |
releaseAllBlockLocks(user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment