message constants
This commit is contained in:
parent
83cb277ba2
commit
c7a3dd16e6
5 changed files with 10 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
||||||
import operations from '../operations';
|
import operations from '../operations';
|
||||||
|
import messages from '../messages';
|
||||||
import * as consoleActions from './console';
|
import * as consoleActions from './console';
|
||||||
import * as tabs from '../background/tabs';
|
import * as tabs from '../background/tabs';
|
||||||
import * as zooms from '../background/zooms';
|
import * as zooms from '../background/zooms';
|
||||||
|
@ -34,7 +35,7 @@ export function exec(operation, tab) {
|
||||||
return consoleActions.showCommand('buffer ');
|
return consoleActions.showCommand('buffer ');
|
||||||
default:
|
default:
|
||||||
return browser.tabs.sendMessage(tab.id, {
|
return browser.tabs.sendMessage(tab.id, {
|
||||||
type: 'require.content.operation',
|
type: messages.CONTENT_OPERATION,
|
||||||
operation
|
operation
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ backgroundStore.subscribe(() => {
|
||||||
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||||
if (tabs.length > 0) {
|
if (tabs.length > 0) {
|
||||||
return browser.tabs.sendMessage(tabs[0].id, {
|
return browser.tabs.sendMessage(tabs[0].id, {
|
||||||
type: 'state.changed',
|
type: messages.STATE_UPDATE,
|
||||||
state: backgroundStore.getState()
|
state: backgroundStore.getState()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ const update = (state) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener((action) => {
|
browser.runtime.onMessage.addListener((action) => {
|
||||||
if (action.type === 'state.changed') {
|
if (action.type === messages.STATE_UPDATE) {
|
||||||
return update(action.state.console);
|
return update(action.state.console);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,6 +5,7 @@ import * as scrolls from '../content/scrolls';
|
||||||
import * as histories from '../content/histories';
|
import * as histories from '../content/histories';
|
||||||
import Follow from '../content/follow';
|
import Follow from '../content/follow';
|
||||||
import operations from '../operations';
|
import operations from '../operations';
|
||||||
|
import messages from '../messages';
|
||||||
|
|
||||||
consoleFrames.initialize(window.document);
|
consoleFrames.initialize(window.document);
|
||||||
|
|
||||||
|
@ -51,9 +52,9 @@ const update = (state) => {
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener((action) => {
|
browser.runtime.onMessage.addListener((action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'state.changed':
|
case messages.STATE_UPDATE:
|
||||||
return update(action.state);
|
return update(action.state);
|
||||||
case 'require.content.operation':
|
case messages.CONTENT_OPERATION:
|
||||||
execOperation(action.operation);
|
execOperation(action.operation);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
export default {
|
export default {
|
||||||
|
STATE_UPDATE: 'state.update',
|
||||||
|
CONTENT_OPERATION: 'content.operation',
|
||||||
|
|
||||||
CONSOLE_BLURRED: 'console.blured',
|
CONSOLE_BLURRED: 'console.blured',
|
||||||
CONSOLE_ENTERED: 'console.entered',
|
CONSOLE_ENTERED: 'console.entered',
|
||||||
CONSOLE_CHANGEED: 'console.changed'
|
CONSOLE_CHANGEED: 'console.changed'
|
||||||
|
|
Reference in a new issue