remove completion actions/reducer
This commit is contained in:
parent
4cb17031d1
commit
45368384d1
13 changed files with 206 additions and 261 deletions
|
@ -6,15 +6,15 @@ export default class Completion {
|
|||
}
|
||||
|
||||
update() {
|
||||
let state = this.store.getState().completion;
|
||||
let state = this.store.getState().console;
|
||||
if (JSON.stringify(this.prevState) === JSON.stringify(state)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.wrapper.innerHTML = '';
|
||||
|
||||
for (let i = 0; i < state.groups.length; ++i) {
|
||||
let group = state.groups[i];
|
||||
for (let i = 0; i < state.completions.length; ++i) {
|
||||
let group = state.completions[i];
|
||||
let title = this.createCompletionTitle(group.name);
|
||||
this.wrapper.append(title);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import messages from 'content/messages';
|
||||
import * as completionActions from 'actions/completion';
|
||||
import * as consoleActions from 'actions/console';
|
||||
|
||||
export default class ConsoleComponent {
|
||||
constructor(wrapper, store) {
|
||||
|
@ -39,9 +39,9 @@ export default class ConsoleComponent {
|
|||
}).then(this.onBlur);
|
||||
case KeyboardEvent.DOM_VK_TAB:
|
||||
if (e.shiftKey) {
|
||||
this.store.dispatch(completionActions.selectPrev());
|
||||
this.store.dispatch(consoleActions.completionPrev());
|
||||
} else {
|
||||
this.store.dispatch(completionActions.selectNext());
|
||||
this.store.dispatch(consoleActions.completionNext());
|
||||
}
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
@ -66,7 +66,7 @@ export default class ConsoleComponent {
|
|||
type: messages.CONSOLE_QUERY_COMPLETIONS,
|
||||
text: e.target.value
|
||||
}).then((completions) => {
|
||||
this.store.dispatch(completionActions.setItems(completions));
|
||||
this.store.dispatch(consoleActions.setCompletions(completions));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,18 @@ export default class ConsoleComponent {
|
|||
this.hideError();
|
||||
}
|
||||
|
||||
if (state.groupSelection >= 0 && state.itemSelection >= 0) {
|
||||
let group = state.completions[state.groupSelection];
|
||||
let item = group.items[state.itemSelection];
|
||||
this.setCommandValue(item.content);
|
||||
} else if (state.completions.length > 0 &&
|
||||
JSON.stringify(this.prevState.completions) ===
|
||||
JSON.stringify(state.completions)) {
|
||||
// Reset input only completion groups not changed (unselected an item in
|
||||
// completion) in order to avoid to override previous input
|
||||
this.setCommandCompletionOrigin();
|
||||
}
|
||||
|
||||
this.prevState = state;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue