Skip to content

Commit

Permalink
Fix error of period limit (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepzh committed Jan 15, 2024
1 parent abbcfa9 commit ae33ced
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
7 changes: 1 addition & 6 deletions src/content-script/limit/delay/button.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { t } from "@src/content-script/locale"
import { LimitReason } from "../common"
import { LINK_STYLE } from "../modal-style"

const canDelay = ({ allowDelay, type }: LimitReason) => allowDelay && (type === "DAILY" || type === "VISIT")

export class DelayButton {
public dom: HTMLDivElement

constructor(reason: LimitReason, onClick: () => void) {
if (!canDelay(reason)) return

constructor(onClick: () => void) {
this.dom = document.createElement('p')
this.dom.style.marginTop = '100px'

Expand Down
17 changes: 10 additions & 7 deletions src/content-script/limit/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ function isSameReason(a: LimitReason, b: LimitReason): boolean {
return same
}

const canDelay = ({ allowDelay, type }: LimitReason) => allowDelay && (type === "DAILY" || type === "VISIT")

class ModalInstance implements MaskModal {
url: string
reasons: LimitReason[] = []
Expand Down Expand Up @@ -162,13 +164,14 @@ class ModalInstance implements MaskModal {
this.mask.append(document.createElement("br"))
this.mask.append(link2Setup(url))

const delayConfirm = new DelayConfirm(this.options)
const delayButton = new DelayButton(
reason,
() => delayConfirm.doConfirm().then(() => this.delayHandlers?.forEach?.(h => h?.()))
)
this.mask.append(delayButton.dom)
this.mask.append(delayConfirm.dom)
if (canDelay(reason)) {
const delayConfirm = new DelayConfirm(this.options)
const delayButton = new DelayButton(
() => delayConfirm.doConfirm().then(() => this.delayHandlers?.forEach?.(h => h?.()))
)
this.mask.append(delayButton.dom)
this.mask.append(delayConfirm.dom)
}

document.body.append(this.mask)
document.body.style.overflow = 'hidden'
Expand Down

0 comments on commit ae33ced

Please sign in to comment.