Skip to content

Commit

Permalink
#237 'Cut', 'Copy' buttons doesn't work - error appears (#238)
Browse files Browse the repository at this point in the history
- update global state initialization
  • Loading branch information
AndreiMazol authored Jan 11, 2021
1 parent ab3895a commit 826f39c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/script/ui/state/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ export function initClipboard(dispatch, getState) {
return {
formats,
focused() {
const state = getState()
const state = global.currentState
return !state.modal
},
onCut() {
const state = getState()
const state = global.currentState
const editor = state.editor
const data = clipData(editor)
if (data) debAction({ tool: 'eraser', opts: 1 })
else editor.selection(null)
return data
},
onCopy() {
const state = getState()
const state = global.currentState
const editor = state.editor
const data = clipData(editor)
editor.selection(null)
Expand Down
19 changes: 11 additions & 8 deletions src/script/ui/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const shared = combineReducers({

/* ROOT REDUCER */
function root(state, action) {
//TODO: temporary solution. Need to review work with redux store
global.currentState = state
switch (
action.type // eslint-disable-line default-case
) {
Expand All @@ -60,12 +58,17 @@ function root(state, action) {
...pick(['editor', 'server', 'options'], state)
})

return sh === state.shared
? state
: {
...state,
...sh
}
const finalState =
sh === state.shared
? state
: {
...state,
...sh
}

//TODO: temporary solution. Need to review work with redux store
global.currentState = finalState
return finalState
}

export default function (options, server) {
Expand Down

0 comments on commit 826f39c

Please sign in to comment.