message: fix(popup): close popup panel after menus being triggered
diff: @@ -51,7 +51,9 @@ getConfig().then(config => {
  message.send({ type: 'OPEN_QS_PANEL' })
  break
  default:
  - sendContextMenusClick(config.baOpen)
  + sendContextMenusClick(config.baOpen).then(() => {
  + window.close()
  + })
  break
  }
  })
  @@ -130,9 +132,13 @@ async function sendContextMenusClick(menuItemId: string) {
  const payload: Message<'CONTEXT_MENUS_CLICK'>['payload'] = {
  menuItemId
  }
  - try {
  - const tabs = await browser.tabs.query({ active: true, currentWindow: true })
  +
  + const tabs = await browser.tabs
  + .query({ active: true, currentWindow: true })
  + .catch((): browser.tabs.Tab[] => [])
  +
  const tab = tabs[0]
  +
  if (tab && tab.url) {
  payload.linkUrl = tab.url
  if (tab.id) {
  @@ -144,14 +150,12 @@ async function sendContextMenusClick(menuItemId: string) {
  payload.selectionText = word.text
  }
  } catch (e) {
  - /* */
  + console.error(e)
  }
  }
  }
  - } catch (e) {
  - /* */
  - }
  - message.send({
  +
  + await message.send({
  type: 'CONTEXT_MENUS_CLICK',
  payload
  })
  