Skip to content

Commit

Permalink
chore: removeAllListeners
Browse files Browse the repository at this point in the history
  • Loading branch information
Yizack committed Oct 20, 2023
1 parent ad3679f commit 3927d4c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/capacitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CapacitorPlugins {
return;
}
if (result.flexibleUpdateAllowed) {
await this.addFlexibleListener();
this.addFlexibleListener();
await AppUpdate.startFlexibleUpdate();
}
}
Expand All @@ -124,14 +124,15 @@ class CapacitorPlugins {
await AppUpdate.completeFlexibleUpdate();
}

async addFlexibleListener () {
addFlexibleListener () {
AppUpdate.addListener("onFlexibleUpdateStateChange", async (state) => {
switch(state) {
case "DOWNLOADING":
this.showToast(t("downloading_update"));
break;
case "DOWNLOADED":
await this.completeFlexibleUpdate();
await AppUpdate.removeAllListeners();
break;
case "FAILED":
this.showToast(t("error_update"));
Expand Down

0 comments on commit 3927d4c

Please sign in to comment.