Skip to content

Commit

Permalink
fix: search engine selecting
Browse files Browse the repository at this point in the history
  • Loading branch information
sentialx committed Sep 21, 2019
1 parent a987218 commit 829cd5f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/renderer/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class Dropdown extends React.PureComponent<Props, State> {
}

componentDidUpdate(prevProps: Props) {
if (this.props.defaultValue !== prevProps) {
if (this.props.defaultValue !== prevProps.defaultValue) {
this.setValue(this.props.defaultValue, false);
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/renderer/views/search/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export class Store {
@observable
public visible = true;

@observable
public searchEngines: ISearchEngine[] = DEFAULT_SEARCH_ENGINES;

@observable
public history: IHistoryItem[] = [];

Expand All @@ -44,13 +41,18 @@ export class Store {
@observable
public inputText = '';

@observable
public settings: ISettings = DEFAULT_SETTINGS;

@computed
public get theme() {
return getTheme(this.settings.theme);
}

@observable
public settings: ISettings = DEFAULT_SETTINGS;
@computed
public get searchEngines() {
return DEFAULT_SEARCH_ENGINES.concat(this.settings.searchEngines);
}

@computed
public get searchedTabs(): ISuggestion[] {
Expand Down Expand Up @@ -79,7 +81,7 @@ export class Store {

@computed
public get searchEngine() {
return this.searchEngines[0];
return this.searchEngines[this.settings.searchEngine];
}

public canSuggest = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const SuggestionsToggle = () => {
};

const onSearchEngineChange = (value: string) => {
const { searchEngines } = store.settings;
const { searchEngines } = store;
store.settings.searchEngine = searchEngines.indexOf(
searchEngines.find(x => x.name === value),
);
Expand Down

0 comments on commit 829cd5f

Please sign in to comment.