Skip to content

Commit

Permalink
chore: rename to toggleRedDot
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Oct 16, 2023
1 parent cf6ca0d commit d653979
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/admin/adminService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class AdminService {

this.adminMode = !!localStorage.getItem(this.cfg.localStorageKey)

if (this.adminMode) this.toggleRedDot()
if (this.adminMode) this.toggleRedDotVisibility()

document.addEventListener('keydown', this.keydownListener.bind(this), { passive: true })

Expand All @@ -107,10 +107,10 @@ export class AdminService {
private async keydownListener(e: KeyboardEvent): Promise<void> {
// console.log(e)
if (!this.cfg.predicate(e)) return
await this.checkToggleRedDot()
await this.toggleRedDot()
}

async checkToggleRedDot(): Promise<void> {
async toggleRedDot(): Promise<void> {
try {
const allow = await this.cfg[this.adminMode ? 'beforeExit' : 'beforeEnter']()
if (!allow) return // no change
Expand All @@ -123,7 +123,7 @@ export class AdminService {

this.adminMode = !this.adminMode

this.toggleRedDot()
this.toggleRedDotVisibility()

if (this.cfg.persistToLocalStorage) {
const { localStorageKey } = this.cfg
Expand All @@ -137,7 +137,7 @@ export class AdminService {
this.cfg.onChange(this.adminMode)
}

private toggleRedDot(): void {
private toggleRedDotVisibility(): void {
this.getRedDotElement().style.display = this.adminMode ? 'block' : 'none'
}

Expand Down

0 comments on commit d653979

Please sign in to comment.