Skip to content

Commit

Permalink
fix(ui): clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonwellsjo committed Oct 16, 2023
1 parent ffad101 commit 9ed248a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/admin/adminService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ export class AdminService {

private listening = false

private touchSequenceIndex = 1
private rightLowerCorner: [xAxis: number, yAxis: number] = [
window.innerWidth - 40,
window.innerHeight - 40,
]
private leftLowerCorner: [xAxis: number, yAxis: number] = [40, window.innerHeight - 40]

/**
* Start listening to keyboard and touch events to toggle AdminMode when detected.
*/
Expand All @@ -117,20 +124,13 @@ export class AdminService {
this.listening = false
}

private sequenceIndex = 1
private rightLowerCorner: [xAxis: number, yAxis: number] = [
window.innerWidth - 40,
window.innerHeight - 40,
]
private leftLowerCorner: [xAxis: number, yAxis: number] = [40, window.innerHeight - 40]

private async touchListener(e: TouchEvent): Promise<void> {
// console.log(e)
const clientX = e.touches[0]?.clientX
const clientY = e.touches[0]?.clientY

if (!clientX || !clientY) {
this.sequenceIndex = 1
this.touchSequenceIndex = 1
return
}

Expand All @@ -142,15 +142,15 @@ export class AdminService {
this.lowerLeftCorner,
]

if (sequence[this.sequenceIndex]!(clientX, clientY)) {
this.sequenceIndex++
if (sequence[this.touchSequenceIndex]!(clientX, clientY)) {
this.touchSequenceIndex++
} else {
this.sequenceIndex = 1
this.touchSequenceIndex = 1
return
}

if (this.sequenceIndex === sequence.length) {
this.sequenceIndex = 1
if (this.touchSequenceIndex === sequence.length) {
this.touchSequenceIndex = 1
await this.checkAllowToggle()
}
}
Expand Down

0 comments on commit 9ed248a

Please sign in to comment.