separate console
This commit is contained in:
parent
22db12f2a3
commit
541449b1fc
13 changed files with 38 additions and 40 deletions
|
@ -1,12 +1,4 @@
|
|||
export default {
|
||||
// console commands
|
||||
CONSOLE_SHOW_COMMAND: 'console.show.command',
|
||||
CONSOLE_SET_COMPLETIONS: 'console.set.completions',
|
||||
CONSOLE_SHOW_ERROR: 'console.show.error',
|
||||
CONSOLE_HIDE: 'console.hide',
|
||||
CONSOLE_COMPLETION_NEXT: 'console.completion.next',
|
||||
CONSOLE_COMPLETION_PREV: 'console.completion.prev',
|
||||
|
||||
// User input
|
||||
INPUT_KEY_PRESS: 'input.key,press',
|
||||
INPUT_CLEAR_KEYS: 'input.clear.keys',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import actions from 'actions';
|
||||
import actions from 'console/actions';
|
||||
|
||||
const showCommand = (text) => {
|
||||
return {
|
9
src/console/actions/index.js
Normal file
9
src/console/actions/index.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
export default {
|
||||
// console commands
|
||||
CONSOLE_SHOW_COMMAND: 'console.show.command',
|
||||
CONSOLE_SET_COMPLETIONS: 'console.set.completions',
|
||||
CONSOLE_SHOW_ERROR: 'console.show.error',
|
||||
CONSOLE_HIDE: 'console.hide',
|
||||
CONSOLE_COMPLETION_NEXT: 'console.completion.next',
|
||||
CONSOLE_COMPLETION_PREV: 'console.completion.prev',
|
||||
};
|
|
@ -6,7 +6,7 @@ export default class Completion {
|
|||
}
|
||||
|
||||
update() {
|
||||
let state = this.store.getState().console;
|
||||
let state = this.store.getState();
|
||||
if (JSON.stringify(this.prevState) === JSON.stringify(state)) {
|
||||
return;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import messages from 'shared/messages';
|
||||
import * as consoleActions from 'actions/console';
|
||||
import * as consoleActions from 'console/actions/console';
|
||||
|
||||
export default class ConsoleComponent {
|
||||
constructor(wrapper, store) {
|
||||
|
@ -71,7 +71,7 @@ export default class ConsoleComponent {
|
|||
}
|
||||
|
||||
update() {
|
||||
let state = this.store.getState().console;
|
||||
let state = this.store.getState();
|
||||
if (!this.prevState.commandShown && state.commandShown) {
|
||||
this.showCommand(state.commandText);
|
||||
} else if (!state.commandShown) {
|
|
@ -1,10 +1,10 @@
|
|||
import './console.scss';
|
||||
import './site.scss';
|
||||
import messages from 'shared/messages';
|
||||
import CompletionComponent from 'components/completion';
|
||||
import ConsoleComponent from 'components/console';
|
||||
import reducers from 'reducers';
|
||||
import CompletionComponent from 'console/components/completion';
|
||||
import ConsoleComponent from 'console/components/console';
|
||||
import reducers from 'console/reducers';
|
||||
import { createStore } from 'store';
|
||||
import * as consoleActions from 'actions/console';
|
||||
import * as consoleActions from 'console/actions/console';
|
||||
|
||||
const store = createStore(reducers);
|
||||
let completionComponent = null;
|
|
@ -1,4 +1,4 @@
|
|||
import actions from 'actions';
|
||||
import actions from 'console/actions';
|
||||
|
||||
const defaultState = {
|
||||
errorShown: false,
|
|
@ -1,11 +1,9 @@
|
|||
import inputReducer from 'reducers/input';
|
||||
import consoleReducer from 'reducers/console';
|
||||
import settingReducer from 'reducers/setting';
|
||||
import followReducer from 'reducers/follow';
|
||||
|
||||
const defaultState = {
|
||||
input: inputReducer(undefined, {}),
|
||||
console: consoleReducer(undefined, {}),
|
||||
setting: settingReducer(undefined, {}),
|
||||
follow: followReducer(undefined, {}),
|
||||
};
|
||||
|
@ -13,7 +11,6 @@ const defaultState = {
|
|||
export default function reducer(state = defaultState, action = {}) {
|
||||
return Object.assign({}, state, {
|
||||
input: inputReducer(state.input, action),
|
||||
console: consoleReducer(state.console, action),
|
||||
setting: settingReducer(state.setting, action),
|
||||
follow: followReducer(state.follow, action),
|
||||
});
|
||||
|
|
Reference in a new issue