Merge pull request #586 from robsmith11/master

Fix warnings on Android
jh-changes
Shin'ya Ueoka 6 years ago committed by GitHub
commit 6ec560bca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/background/presenters/IndicatorPresenter.ts
  2. 6
      src/background/usecases/CompletionsUseCase.ts
  3. 7
      src/background/usecases/LinkUseCase.ts

@ -3,7 +3,13 @@ export default class IndicatorPresenter {
let path = enabled let path = enabled
? 'resources/enabled_32x32.png' ? 'resources/enabled_32x32.png'
: 'resources/disabled_32x32.png'; : 'resources/disabled_32x32.png';
return browser.browserAction.setIcon({ path }); if (typeof browser.browserAction.setIcon === "function") {
return browser.browserAction.setIcon({ path });
}
else {
// setIcon not supported on Android
return Promise.resolve();
}
} }
onClick(listener: (arg: browser.tabs.Tab) => void): void { onClick(listener: (arg: browser.tabs.Tab) => void): void {

@ -52,13 +52,15 @@ export default class CompletionsUseCase {
if (engines.length > 0) { if (engines.length > 0) {
groups.push({ name: 'Search Engines', items: engines }); groups.push({ name: 'Search Engines', items: engines });
} }
} else if (c === 'h') { // browser.history not supported on Android
} else if (c === 'h' && typeof browser.history === "object") {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
let histories = await this.queryHistoryItems(name, keywords); let histories = await this.queryHistoryItems(name, keywords);
if (histories.length > 0) { if (histories.length > 0) {
groups.push({ name: 'History', items: histories }); groups.push({ name: 'History', items: histories });
} }
} else if (c === 'b') { // browser.bookmarks not supported on Android
} else if (c === 'b' && typeof browser.bookmarks === "object") {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
let bookmarks = await this.queryBookmarkItems(name, keywords); let bookmarks = await this.queryBookmarkItems(name, keywords);
if (bookmarks.length > 0) { if (bookmarks.length > 0) {

@ -12,8 +12,9 @@ export default class LinkUseCase {
} }
openNewTab(url: string, openerId: number, background: boolean): Promise<any> { openNewTab(url: string, openerId: number, background: boolean): Promise<any> {
return this.tabPresenter.create(url, { // openerTabId not supported on Android
openerTabId: openerId, active: !background let properties = typeof browser.tabs.Tab === "object" ?
}); { openerTabId: openerId, active: !background } : { active: !background };
return this.tabPresenter.create(url, properties);
} }
} }