-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
57 additions
and
55 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 was deleted.
Oops, something went wrong.
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,27 @@ | ||
import { LIFTED_ACTION, SELECT_INSTANCE } from 'remotedev-app/lib/constants/actionTypes'; | ||
import { getActiveInstance } from 'remotedev-app/lib/reducers/instances'; | ||
|
||
function panelDispatcher(bgConnection) { | ||
let autoselected = false; | ||
const tabId = chrome.devtools.inspectedWindow.tabId; | ||
|
||
return store => next => action => { | ||
const result = next(action); | ||
if (!autoselected) { | ||
autoselected = true; | ||
const connections = store.getState() | ||
.instances.connections[tabId]; | ||
if (connections && connections.length === 1) { | ||
next({ type: SELECT_INSTANCE, selected: connections[0] }); | ||
} | ||
} | ||
if (action.type === LIFTED_ACTION) { | ||
const instances = store.getState().instances; | ||
const instanceId = getActiveInstance(instances); | ||
bgConnection.postMessage({ ...action, instanceId, id: tabId }); | ||
} | ||
return result; | ||
}; | ||
} | ||
|
||
export default panelDispatcher; |
File renamed without changes.
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { createStore, applyMiddleware } from 'redux'; | ||
import persist from 'remotedev-app/lib/middlewares/persist'; | ||
import panelDispatcher from '../middlewares/panelDispatcher'; | ||
import panelDispatcher from '../middlewares/panelSync'; | ||
import rootReducer from '../reducers/panel'; | ||
|
||
export default function configureStore(position, preloadedState) { | ||
return createStore(rootReducer, preloadedState, applyMiddleware(persist(position), panelDispatcher)); | ||
export default function configureStore(position, bgConnection, preloadedState) { | ||
const enhancer = applyMiddleware(persist(position), panelDispatcher(bgConnection)); | ||
return createStore(rootReducer, preloadedState, enhancer); | ||
} |
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