Refactor background directories
This commit is contained in:
parent
c5c08783d2
commit
98bc2326ee
9 changed files with 19 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
||||||
import actions from '../actions';
|
import actions from '../actions';
|
||||||
import * as tabs from 'background/tabs';
|
import * as tabs from '../shared/tabs';
|
||||||
import * as parsers from 'shared/commands/parsers';
|
import * as parsers from 'shared/commands/parsers';
|
||||||
import * as properties from 'shared/settings/properties';
|
import * as properties from 'shared/settings/properties';
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as commandActions from 'background/actions/command';
|
||||||
import * as settingActions from 'background/actions/setting';
|
import * as settingActions from 'background/actions/setting';
|
||||||
import * as findActions from 'background/actions/find';
|
import * as findActions from 'background/actions/find';
|
||||||
import * as tabActions from 'background/actions/tab';
|
import * as tabActions from 'background/actions/tab';
|
||||||
import * as commands from 'shared/commands';
|
import * as completions from '../shared/completions';
|
||||||
|
|
||||||
export default class BackgroundComponent {
|
export default class BackgroundComponent {
|
||||||
constructor(store) {
|
constructor(store) {
|
||||||
|
@ -44,7 +44,7 @@ export default class BackgroundComponent {
|
||||||
case messages.SETTINGS_QUERY:
|
case messages.SETTINGS_QUERY:
|
||||||
return Promise.resolve(this.store.getState().setting.value);
|
return Promise.resolve(this.store.getState().setting.value);
|
||||||
case messages.CONSOLE_QUERY_COMPLETIONS:
|
case messages.CONSOLE_QUERY_COMPLETIONS:
|
||||||
return commands.complete(message.text, settings.value);
|
return completions.complete(message.text, settings.value);
|
||||||
case messages.SETTINGS_RELOAD:
|
case messages.SETTINGS_RELOAD:
|
||||||
this.store.dispatch(settingActions.load());
|
this.store.dispatch(settingActions.load());
|
||||||
return this.broadcastSettingsChanged();
|
return this.broadcastSettingsChanged();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import messages from 'shared/messages';
|
import messages from 'shared/messages';
|
||||||
import operations from 'shared/operations';
|
import operations from 'shared/operations';
|
||||||
import * as tabs from 'background/tabs';
|
import * as tabs from '../shared//tabs';
|
||||||
import * as zooms from 'background/zooms';
|
import * as zooms from '../shared/zooms';
|
||||||
|
|
||||||
export default class BackgroundComponent {
|
export default class BackgroundComponent {
|
||||||
constructor(store) {
|
constructor(store) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as tabs from 'background/tabs';
|
import * as tabs from './tabs';
|
||||||
import * as histories from 'background/histories';
|
import * as histories from './histories';
|
||||||
|
|
||||||
const getOpenCompletions = (command, keywords, searchConfig) => {
|
const getOpenCompletions = (command, keywords, searchConfig) => {
|
||||||
return histories.getCompletions(keywords).then((pages) => {
|
return histories.getCompletions(keywords).then((pages) => {
|
||||||
|
@ -81,4 +81,4 @@ const complete = (line, settings) => {
|
||||||
return getCompletions(line, settings);
|
return getCompletions(line, settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default complete;
|
export { complete };
|
10
src/background/shared/completions/tabs.js
Normal file
10
src/background/shared/completions/tabs.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
const getCompletions = (keyword) => {
|
||||||
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
||||||
|
let matched = tabs.filter((t) => {
|
||||||
|
return t.url.includes(keyword) || t.title && t.title.includes(keyword);
|
||||||
|
});
|
||||||
|
return matched;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export { getCompletions };
|
|
@ -66,15 +66,6 @@ const selectByKeyword = (current, keyword) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCompletions = (keyword) => {
|
|
||||||
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
|
||||||
let matched = tabs.filter((t) => {
|
|
||||||
return t.url.includes(keyword) || t.title && t.title.includes(keyword);
|
|
||||||
});
|
|
||||||
return matched;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectPrevTab = (current, count) => {
|
const selectPrevTab = (current, count) => {
|
||||||
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
||||||
if (tabs.length < 2) {
|
if (tabs.length < 2) {
|
||||||
|
@ -139,7 +130,7 @@ const duplicate = (id) => {
|
||||||
|
|
||||||
export {
|
export {
|
||||||
closeTab, closeTabForce, reopenTab, selectAt, selectByKeyword,
|
closeTab, closeTabForce, reopenTab, selectAt, selectByKeyword,
|
||||||
getCompletions, selectPrevTab, selectNextTab, selectFirstTab,
|
selectPrevTab, selectNextTab, selectFirstTab,
|
||||||
selectLastTab, selectPrevSelTab, reload, updateTabPinned,
|
selectLastTab, selectPrevSelTab, reload, updateTabPinned,
|
||||||
toggleTabPinned, duplicate
|
toggleTabPinned, duplicate
|
||||||
};
|
};
|
|
@ -1,3 +0,0 @@
|
||||||
import complete from './complete';
|
|
||||||
|
|
||||||
export { complete };
|
|
Reference in a new issue