Skip to content

Commit

Permalink
Fix removing the instance from devpanel
Browse files Browse the repository at this point in the history
  • Loading branch information
zalmoxisus committed Sep 16, 2016
1 parent c0f00d6 commit cf76ab7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/app/middlewares/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getReport } from '../../browser/extension/background/logging';

const CONNECTED = 'socket/CONNECTED';
const DISCONNECTED = 'socket/DISCONNECTED';
const naMessage = { type: 'NA' };
const connections = {
tab: {},
panel: {},
Expand Down Expand Up @@ -116,7 +115,7 @@ function disconnect(type, id, listener) {
return function disconnectListener() {
if (type === 'tab') {
window.store.dispatch({ type: REMOVE_INSTANCE, id });
toMonitors(naMessage);
toMonitors({ type: 'NA', id });
} else {
monitors--;
if (!monitors) monitorInstances(false);
Expand Down
9 changes: 7 additions & 2 deletions src/browser/extension/devpanel/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Provider } from 'react-redux';
import { REMOVE_INSTANCE } from 'remotedev-app/lib/constants/actionTypes';
import App from '../../../app/containers/App';
import configureStore from '../../../app/stores/panelStore';
import getPreloadedState from '../background/getPreloadedState';
Expand Down Expand Up @@ -31,12 +32,15 @@ function renderNA() {
if (rendered === false) return;
rendered = false;
naTimeout = setTimeout(() => {
const node = document.getElementById('root');
unmountComponentAtNode(node);
render(
<div style={{ padding: '20px', width: '100%', textAlign: 'center' }}>
No store found. Make sure to follow <a href="https://github.com/zalmoxisus/redux-devtools-extension#usage" target="_blank">the instructions</a>.
</div>,
document.getElementById('root')
node
);
store = undefined;
}, 1500);
}

Expand All @@ -45,7 +49,8 @@ function init(id) {
bgConnection = chrome.runtime.connect({ name: id.toString() });
bgConnection.onMessage.addListener(message => {
if (message.type === 'NA') {
renderNA();
if (message.id === id) renderNA();
else store.dispatch({ type: REMOVE_INSTANCE, id: message.id });
} else {
if (!rendered) renderDevTools();
store.dispatch(message);
Expand Down

0 comments on commit cf76ab7

Please sign in to comment.