Skip to content

Commit 83696d6

Browse files
authored
Merge pull request #100 from grahamas/master
Add toggle to keep/remove the locale dropdown in the search modal
2 parents c783d05 + 4e3b008 commit 83696d6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/settings/settings.ts

+13
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface BookSearchPluginSettings {
3333
showCoverImageInSearch: boolean;
3434
enableCoverImageSave: boolean;
3535
coverImagePath: string;
36+
askForLocale: boolean;
3637
}
3738

3839
export const DEFAULT_SETTINGS: BookSearchPluginSettings = {
@@ -52,6 +53,7 @@ export const DEFAULT_SETTINGS: BookSearchPluginSettings = {
5253
showCoverImageInSearch: false,
5354
enableCoverImageSave: false,
5455
coverImagePath: '',
56+
askForLocale: true,
5557
};
5658

5759
export class BookSearchSettingTab extends PluginSettingTab {
@@ -284,6 +286,17 @@ export class BookSearchSettingTab extends PluginSettingTab {
284286
}),
285287
);
286288

289+
// A toggle whether or not to ask for the locale every time a search is made
290+
new Setting(containerEl)
291+
.setName('Ask for Locale')
292+
.setDesc('Toggle to enable or disable asking for the locale every time a search is made.')
293+
.addToggle(toggle =>
294+
toggle.setValue(this.plugin.settings.askForLocale).onChange(async value => {
295+
this.plugin.settings.askForLocale = value;
296+
await this.plugin.saveSettings();
297+
}),
298+
);
299+
287300
new Setting(containerEl)
288301
.setName('Enable Cover Image Save')
289302
.setDesc('Toggle to enable or disable saving cover images in notes.')

src/views/book_search_modal.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export class BookSearchModal extends Modal {
4949
onOpen(): void {
5050
const { contentEl } = this;
5151
contentEl.createEl('h2', { text: 'Search Book' });
52-
if (this.plugin.settings.serviceProvider === ServiceProvider.google) this.renderSelectLocale();
52+
if (this.plugin.settings.serviceProvider === ServiceProvider.google && this.plugin.settings.askForLocale)
53+
this.renderSelectLocale();
5354
contentEl.createDiv({ cls: 'book-search-plugin__search-modal--input' }, el => {
5455
new TextComponent(el)
5556
.setValue(this.query)

0 commit comments

Comments
 (0)