diff --git a/src/services/drag-and-drop.actions.ts b/src/services/drag-and-drop.actions.ts index c6c460ad..fa9db3a5 100644 --- a/src/services/drag-and-drop.actions.ts +++ b/src/services/drag-and-drop.actions.ts @@ -1211,11 +1211,17 @@ export async function onDragEnd(e: DragEvent): Promise { // Check if the drop event was consumed by another sidebar const requestingDropStatus: Promise[] = [] for (const win of Windows.otherWindows) { - if (win.id) requestingDropStatus.push(IPC.sidebar(win.id, 'isDropEventConsumed')) + if (win.id) { + const gettingStatus = browser.sidebarAction.isOpen({ windowId: win.id }).then(isOpen => { + if (isOpen && win.id) return IPC.sidebar(win.id, 'isDropEventConsumed') + else return false + }) + requestingDropStatus.push(gettingStatus) + } } let consumed try { - consumed = await Promise.all(requestingDropStatus) + consumed = await Utils.deadline(1500, [], Promise.all(requestingDropStatus)) } catch (err) { Logs.err('DnD.onDragEnd: Cannot get drop status from other windows', err) return diff --git a/src/utils.ts b/src/utils.ts index 70120d93..8d33e2c2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -115,6 +115,16 @@ export async function sleep(ms = 1000): Promise { }) } +/** + * Deadline + */ +export function deadline(deadline: number, fallback: T, promise: Promise): Promise { + return new Promise((ok, meh) => { + setTimeout(() => ok(fallback), deadline) + promise.then(ok).catch(meh) + }) +} + /** * Bytes to readable string */