Skip to content

Commit

Permalink
Make overlay close action singleUse
Browse files Browse the repository at this point in the history
fix #6580
  • Loading branch information
murilopereirame committed Feb 23, 2024
1 parent 9c15b89 commit 149c1fd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/gui/base/Overlay.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import m, { Children, Component, VnodeDOM } from "mithril"
import { LayerType } from "../../RootView"
import type { lazy } from "@tutao/tutanota-utils"
import { lazy, makeSingleUse } from "@tutao/tutanota-utils"
import { assertMainOrNodeBoot } from "../../api/common/Env"
import { px, size } from "../size.js"
import { styles } from "../styles.js"
import { getSafeAreaInsetBottom } from "../HtmlUtils.js"
import { ProgrammingError } from "../../api/common/error/ProgrammingError.js"

assertMainOrNodeBoot()
export type PositionRect = {
Expand Down Expand Up @@ -49,12 +48,14 @@ export function displayOverlay(
// Add the new overlay into the overlay container
overlays.set(overlayKey, pair)

return () => {
// Make single so fast taps doesn't try to remove
// the same overlay twice
return makeSingleUse(() => {
// Remove the overlay & error if unsuccessful
if (!overlays.delete(overlayKey)) {
throw new ProgrammingError(`Failed to remove overlay with key:${overlayKey}!`)
console.warn(`Missing overlay with key:${overlayKey}!`)
}
}
}) as () => void
}

export const overlay: Component = {
Expand Down

0 comments on commit 149c1fd

Please sign in to comment.