Skip to content

Commit

Permalink
Remove handlersToCancel on web. (#2679)
Browse files Browse the repository at this point in the history
## Description

While working on removing [gesture handlers limit on android](#2672) I've though that we can also remove `handlersToCancel` array on web.

## Test plan

Tested on example app.
  • Loading branch information
m-bert authored Nov 21, 2023
1 parent 510905e commit 09adf84
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/web/tools/GestureHandlerOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default class GestureHandlerOrchestrator {

private gestureHandlers: GestureHandler[] = [];
private awaitingHandlers: GestureHandler[] = [];
private handlersToCancel: GestureHandler[] = [];

private handlingChangeSemaphore = 0;
private activationIndex = 0;
Expand All @@ -34,7 +33,6 @@ export default class GestureHandlerOrchestrator {
public removeHandlerFromOrchestrator(handler: GestureHandler): void {
this.gestureHandlers.splice(this.gestureHandlers.indexOf(handler), 1);
this.awaitingHandlers.splice(this.awaitingHandlers.indexOf(handler), 1);
this.handlersToCancel.splice(this.handlersToCancel.indexOf(handler), 1);
}

private cleanupFinishedHandlers(): void {
Expand Down Expand Up @@ -177,17 +175,12 @@ export default class GestureHandlerOrchestrator {
handler.setShouldResetProgress(true);
handler.setActivationIndex(this.activationIndex++);

this.gestureHandlers.forEach((otherHandler) => {
// Order of arguments is correct - we check whether current handler should cancel existing handlers

if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {
this.handlersToCancel.push(otherHandler);
for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {
if (this.shouldHandlerBeCancelledBy(this.gestureHandlers[i], handler)) {
this.gestureHandlers[i].cancel();
}
});

for (let i = this.handlersToCancel.length - 1; i >= 0; --i) {
this.handlersToCancel[i]?.cancel();
}

this.awaitingHandlers.forEach((otherHandler) => {
if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {
otherHandler?.cancel();
Expand All @@ -212,8 +205,6 @@ export default class GestureHandlerOrchestrator {
}
}
}

this.handlersToCancel = [];
}

private addAwaitingHandler(handler: GestureHandler): void {
Expand Down

0 comments on commit 09adf84

Please sign in to comment.