diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-29 20:07:23 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-29 20:07:23 +0900 |
commit | 68673957edad21700c58d252542a0aee04115d22 (patch) | |
tree | 7a58c00d82372a27b03fcbcdbf63d3fc7ec52c39 /src | |
parent | aea17a52d692310ac459410c7d6b4e0bfd5e0225 (diff) | |
parent | 698f905145755954647f91ae01f5966b9e35a91e (diff) |
Merge pull request #596 from ueokande/qa-0.23
QA 0.23
Diffstat (limited to 'src')
-rw-r--r-- | src/background/usecases/CompletionsUseCase.ts | 5 | ||||
-rw-r--r-- | src/content/usecases/FollowSlaveUseCase.ts | 10 | ||||
-rw-r--r-- | src/settings/components/form/SearchForm.tsx | 7 | ||||
-rw-r--r-- | src/settings/components/index.tsx | 2 | ||||
-rw-r--r-- | src/settings/keymaps.ts | 12 | ||||
-rw-r--r-- | src/shared/Settings.ts | 28 |
6 files changed, 41 insertions, 23 deletions
diff --git a/src/background/usecases/CompletionsUseCase.ts b/src/background/usecases/CompletionsUseCase.ts index 705555b..8cd4f32 100644 --- a/src/background/usecases/CompletionsUseCase.ts +++ b/src/background/usecases/CompletionsUseCase.ts @@ -38,6 +38,9 @@ export default class CompletionsUseCase { } async queryOpen(name: string, keywords: string): Promise<CompletionGroup[]> { + // TODO This logic contains view entities. They should be defined on + // content script + let settings = await this.settingRepository.get(); let groups: CompletionGroup[] = []; @@ -195,7 +198,7 @@ export default class CompletionsUseCase { .map(pages => filters.filterByPathname(pages, COMPLETION_ITEM_LIMIT)) .map(pages => filters.filterByOrigin(pages, COMPLETION_ITEM_LIMIT))[0] .sort((x: HistoryItem, y: HistoryItem): number => { - return Number(x.visitCount) - Number(y.visitCount); + return Number(y.visitCount) - Number(x.visitCount); }) .slice(0, COMPLETION_ITEM_LIMIT); return histories.map(page => ({ diff --git a/src/content/usecases/FollowSlaveUseCase.ts b/src/content/usecases/FollowSlaveUseCase.ts index a2cc80e..2bd16ee 100644 --- a/src/content/usecases/FollowSlaveUseCase.ts +++ b/src/content/usecases/FollowSlaveUseCase.ts @@ -63,16 +63,16 @@ export default class FollowSlaveUseCase { if (hint instanceof LinkHint) { let url = hint.getLink(); - // ignore taget='_blank' - if (!newTab && hint.getLinkTarget() === '_blank') { - hint.click(); - return; + let openNewTab = newTab; + // Open link by background script in order to prevent a popup block + if (hint.getLinkTarget() === '_blank') { + openNewTab = true; } // eslint-disable-next-line no-script-url if (!url || url === '#' || url.toLowerCase().startsWith('javascript:')) { return; } - await this.tabsClient.openUrl(url, newTab, background); + await this.tabsClient.openUrl(url, openNewTab, background); } else if (hint instanceof InputHint) { hint.activate(); } diff --git a/src/settings/components/form/SearchForm.tsx b/src/settings/components/form/SearchForm.tsx index cf78a69..6ba6cfb 100644 --- a/src/settings/components/form/SearchForm.tsx +++ b/src/settings/components/form/SearchForm.tsx @@ -54,6 +54,7 @@ class SearchForm extends React.Component<Props> { </div>; } + // eslint-disable-next-line max-statements bindValue(e: any) { let value = this.props.value.toJSON(); let name = e.target.name; @@ -72,8 +73,12 @@ class SearchForm extends React.Component<Props> { next.default = value.engines[index][0]; } else if (name === 'add') { next.engines.push(['', '']); - } else if (name === 'delete') { + } else if (name === 'delete' && value.engines.length > 1) { next.engines.splice(index, 1); + if (value.engines[index][0] === value.default) { + let nextIndex = Math.min(index, next.engines.length - 1); + next.default = next.engines[nextIndex][0]; + } } this.props.onChange(FormSearch.valueOf(next)); diff --git a/src/settings/components/index.tsx b/src/settings/components/index.tsx index b4a0866..eeac2cf 100644 --- a/src/settings/components/index.tsx +++ b/src/settings/components/index.tsx @@ -175,6 +175,7 @@ class SettingsComponent extends React.Component<Props> { if (from === 'form' && value === 'json') { this.props.dispatch(settingActions.switchToJson( this.props.form as FormSettings)); + this.save(); } else if (from === 'json' && value === 'form') { let b = window.confirm(DO_YOU_WANT_TO_CONTINUE); if (!b) { @@ -183,6 +184,7 @@ class SettingsComponent extends React.Component<Props> { } this.props.dispatch( settingActions.switchToForm(this.props.json as JSONSettings)); + this.save(); } } diff --git a/src/settings/keymaps.ts b/src/settings/keymaps.ts index e2afa4d..33ad26d 100644 --- a/src/settings/keymaps.ts +++ b/src/settings/keymaps.ts @@ -1,3 +1,5 @@ +/* eslint-disable max-len */ + const fields = [ [ ['scroll.vertically?{"count":1}', 'Scroll down'], @@ -19,8 +21,8 @@ const fields = [ ['tabs.close', 'Close a tab'], ['tabs.close.right', 'Close tabs to the right'], ['tabs.reopen', 'Reopen closed tab'], - ['tabs.next?{"count":1}', 'Select next Tab'], - ['tabs.prev?{"count":1}', 'Select prev Tab'], + ['tabs.next', 'Select next Tab'], + ['tabs.prev', 'Select prev Tab'], ['tabs.first', 'Select first tab'], ['tabs.last', 'Select last tab'], ['tabs.reload?{"cache":false}', 'Reload current tab'], @@ -28,8 +30,8 @@ const fields = [ ['tabs.pin.toggle', 'Toggle pinned state'], ['tabs.duplicate', 'Duplicate a tab'], ], [ - ['follow.start?{"newTab":false}', 'Follow a link'], - ['follow.start?{"newTab":true}', 'Follow a link in new tab'], + ['follow.start?{"newTab":false,"background":false}', 'Follow a link'], + ['follow.start?{"newTab":true,"background":false}', 'Follow a link in new tab'], ['navigate.history.prev', 'Go back in histories'], ['navigate.history.next', 'Go forward in histories'], ['navigate.link.next', 'Open next link'], @@ -37,7 +39,7 @@ const fields = [ ['navigate.parent', 'Go to parent directory'], ['navigate.root', 'Go to root directory'], ['page.source', 'Open page source'], - ['page.home', 'Open start page to current tab'], + ['page.home?{"newTab":false}', 'Open start page to current tab'], ['page.home?{"newTab":true}', 'Open start page in new tab'], ['focus.input', 'Focus input'], ], [ diff --git a/src/shared/Settings.ts b/src/shared/Settings.ts index e1e2046..0bef342 100644 --- a/src/shared/Settings.ts +++ b/src/shared/Settings.ts @@ -101,17 +101,23 @@ export const blacklistValueOf = (o: any): string[] => { export const valueOf = (o: any): Settings => { let settings = { ...DefaultSetting }; - if (Object.prototype.hasOwnProperty.call(o, 'keymaps')) { - settings.keymaps = keymapsValueOf(o.keymaps); - } - if (Object.prototype.hasOwnProperty.call(o, 'search')) { - settings.search = searchValueOf(o.search); - } - if (Object.prototype.hasOwnProperty.call(o, 'properties')) { - settings.properties = propertiesValueOf(o.properties); - } - if (Object.prototype.hasOwnProperty.call(o, 'blacklist')) { - settings.blacklist = blacklistValueOf(o.blacklist); + for (let key of Object.keys(o)) { + switch (key) { + case 'keymaps': + settings.keymaps = keymapsValueOf(o.keymaps); + break; + case 'search': + settings.search = searchValueOf(o.search); + break; + case 'properties': + settings.properties = propertiesValueOf(o.properties); + break; + case 'blacklist': + settings.blacklist = blacklistValueOf(o.blacklist); + break; + default: + throw new TypeError('unknown setting: ' + key); + } } return settings; }; |