mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-01 10:22:25 +00:00
Debounce zap popover open while warm
This commit is contained in:
1 parent
7356dc06af
commit
d47aa1d4fa
1 file changed
+17
-7
+17
-7
@@ -929,15 +929,16 @@ function focusZapAmountField() {
|
||||
}
|
||||
|
||||
function isZapControlsOpen() {
|
||||
if (zapPopoverOpenPromise) {
|
||||
return true;
|
||||
}
|
||||
if (typeof zapPopover?.isOpen === "function") {
|
||||
return zapPopover.isOpen();
|
||||
}
|
||||
return zapControlsOpen;
|
||||
}
|
||||
|
||||
function isZapControlsOpening() {
|
||||
return Boolean(zapPopoverOpenPromise) && !isZapControlsOpen();
|
||||
}
|
||||
|
||||
async function openZapControls({ focus = false } = {}) {
|
||||
const zapButton = getChannelZapButton();
|
||||
if (!zapButton) {
|
||||
@@ -970,6 +971,9 @@ async function openZapControls({ focus = false } = {}) {
|
||||
}
|
||||
|
||||
if (zapPopoverOpenPromise) {
|
||||
if (focus) {
|
||||
zapShouldFocusOnOpen = true;
|
||||
}
|
||||
try {
|
||||
return await zapPopoverOpenPromise;
|
||||
} catch (error) {
|
||||
@@ -1700,12 +1704,14 @@ async function handleZapButtonClick(event) {
|
||||
return;
|
||||
}
|
||||
|
||||
const popoverIsOpen =
|
||||
typeof zapPopover?.isOpen === "function"
|
||||
? zapPopover.isOpen()
|
||||
: isZapControlsOpen();
|
||||
const opening = isZapControlsOpening();
|
||||
const popoverIsOpen = isZapControlsOpen();
|
||||
|
||||
if (!popoverIsOpen) {
|
||||
if (opening) {
|
||||
zapShouldFocusOnOpen = true;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await openZapControls({ focus: true });
|
||||
} catch (error) {
|
||||
@@ -1714,6 +1720,10 @@ async function handleZapButtonClick(event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (opening) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (zapInFlight) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user