Skip to content

Commit

Permalink
Remove buggy autoclose behaviour of extension popup's
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustem Mussabekov committed Nov 6, 2023
1 parent 375c7b7 commit d9cb239
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "5.6.17",
"version": "5.6.18",
"description": "",
"author": "",
"license": "ISC",
Expand Down
4 changes: 2 additions & 2 deletions src/target/extension/background/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ async function onClicked({ menuItemId, pageUrl, srcUrl, linkUrl }, { windowId })
return open('/extension/tabs/-1')

case 'open_app':
return open('/', { width: 1280, height: 800, autoClose: false })
return open('/', { width: 1280, height: 800 })

case 'settings':
return open('/settings', { width: 800, height: 700, autoClose: false })
return open('/settings', { width: 800, height: 700 })

case 'execute_side_panel':
if (browser.sidePanel)
Expand Down
20 changes: 2 additions & 18 deletions src/target/extension/background/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import { environment } from '~target'
const base = environment.includes('safari') ?
'https://app.raindrop.io' :
'/index.html#'
const winIds = new Set()

export async function open(path, { width = 420, height = 600, autoClose = true } = {}) {
export async function open(path, { width = 420, height = 600 } = {}) {
let origin = { left: 0, top: 0, width: 0, height: 0 }
try{
origin = await browser.windows.getCurrent()
} catch(_) {}

const { id } = await browser.windows.create({
return await browser.windows.create({
url: `${base}${path}`,
type: 'popup',

Expand All @@ -23,22 +22,7 @@ export async function open(path, { width = 420, height = 600, autoClose = true }
left: parseInt(origin.left + (origin.width/2) - (width/2)),
top: parseInt(origin.top + (origin.height/2) - (height/2))
})

//delay autoclose on blur, otherwise buggy on arch linux
if (autoClose)
setTimeout(() => { winIds.add(id) }, 100)
}

/* Close all open popups when focused window change */
function onFocusChanged(id) {
for(const close of winIds)
if (close != id) {
try { browser.windows.remove(close) } catch(e) {}
winIds.delete(close)
}
}

export default function() {
browser.windows.onFocusChanged.removeListener(onFocusChanged)
browser.windows.onFocusChanged.addListener(onFocusChanged)
}

0 comments on commit d9cb239

Please sign in to comment.