feat: activate existing conversation window by default (#222)

This commit is contained in:
josc146
2023-04-21 22:18:09 +08:00
parent 2f832a0f5b
commit 3658d123e0
6 changed files with 56 additions and 25 deletions
+13 -6
View File
@@ -1,6 +1,7 @@
import { getCoreContentText } from '../../utils/get-core-content-text'
import { openUrl } from '../../utils/open-url'
import Browser from 'webextension-polyfill'
import { getUserConfig } from '../../config/index.mjs'
export const config = {
newChat: {
@@ -24,12 +25,18 @@ export const config = {
openConversationWindow: {
label: 'Open Conversation Window',
action: async () => {
Browser.windows.create({
url: Browser.runtime.getURL('IndependentPanel.html'),
type: 'popup',
width: 500,
height: 650,
})
const config = await getUserConfig()
const url = Browser.runtime.getURL('IndependentPanel.html')
const tabs = await Browser.tabs.query({ url: url, windowType: 'popup' })
if (!config.alwaysCreateNewConversationWindow && tabs.length > 0)
await Browser.windows.update(tabs[0].windowId, { focused: true })
else
await Browser.windows.create({
url: url,
type: 'popup',
width: 500,
height: 650,
})
},
},
}