Skip to content

Commit

Permalink
[fix] #155
Browse files Browse the repository at this point in the history
  • Loading branch information
VecHK committed Jul 11, 2022
1 parent 8417382 commit cd741f9
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/core/layout/window-revert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,39 @@ import { getSearchWindowTabURL, getWindowId, WindowID } from './window'

const revertOperate = Atomic()

export default function WindowRevert(base: Base) {
async function revertWindowExists(
base: Pick<Base, 'getRevertContainerId' | 'setRevertContainerId'>
): Promise<WindowID | false> {
const { getRevertContainerId, setRevertContainerId } = base
const revert_container_id = getRevertContainerId()
if (revert_container_id === undefined) {
return false
} else {
try {
if (Boolean(
await chrome.windows.get(revert_container_id)
)) {
return revert_container_id
} else {
return false
}
} catch (err) {
setRevertContainerId(undefined)
return false
}
}
}

export default function WindowRevert(base: Base) {
const { setRevertContainerId } = base

return (
async function revert(search_window_id: WindowID): Promise<void> {
revertOperate(async () => {
const url_P = getSearchWindowTabURL(search_window_id)

const revert_container_id = getRevertContainerId()
if (revert_container_id !== undefined) {
const revert_container_id = await revertWindowExists(base)
if (revert_container_id !== false) {
await chrome.windows.update(search_window_id, {
state: 'normal'
})
Expand Down

0 comments on commit cd741f9

Please sign in to comment.