From 3e37b5473eb9fc7f6d150ac6d64a0daef5c98348 Mon Sep 17 00:00:00 2001 From: Ayce <32338891+Ayce45@users.noreply.github.com> Date: Thu, 9 Dec 2021 12:08:21 +0100 Subject: [PATCH] fix: vaccine-injection (#88) --- browser_action/index.js | 2 +- commons/AppStatus.js | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/browser_action/index.js b/browser_action/index.js index 2842327..c1c662b 100644 --- a/browser_action/index.js +++ b/browser_action/index.js @@ -136,7 +136,7 @@ appStatus.setInjectionType.bind(appStatus, "thirdInjectionOnly"); document.getElementById("modernaInjection").onclick = - appStatus.setInjectionVaccine.bind(appStatus, "pfizerInjection"); + appStatus.setInjectionVaccine.bind(appStatus, "modernaInjection"); document.getElementById("pfizerInjection").onclick = appStatus.setInjectionVaccine.bind(appStatus, "pfizerInjection"); diff --git a/commons/AppStatus.js b/commons/AppStatus.js index 4d7e5cf..34f41b3 100644 --- a/commons/AppStatus.js +++ b/commons/AppStatus.js @@ -32,7 +32,7 @@ class AppStatus { this.onAutoBookChangeCb = (newValue) => {}; /** @type {('fullServiceInjection' | 'firstInjectionOnly' | 'secondInjectionOnly' | 'thirdInjectionOnly') => void} callback quand injectionType change de valeur */ this.onInjectionTypeCb = (newValue) => {}; - /** @type {'modernaInjection' | 'pfizerInjection'} callback quand injectionType change de valeur */ + /** @type {'modernaInjection' | 'pfizerInjection'} callback quand injectionVaccine change de valeur */ this.onInjectionVaccineCb = (newValue) => {}; this.onStorageChange = this.onStorageChange.bind(this); @@ -48,6 +48,7 @@ class AppStatus { stopped: false, autoBook: false, injectionType: "fullServiceInjection", + injectionVaccine: "modernaInjection", }); Object.keys(result.locations).forEach((url) => { @@ -63,6 +64,9 @@ class AppStatus { this.injectionType = result.injectionType; this.onInjectionTypeCb(this.injectionType); + + this.injectionVaccine = result.injectionVaccine; + this.onInjectionVaccineCb(this.injectionVaccine); } getLocations() { @@ -135,7 +139,7 @@ class AppStatus { * @param {('modernaInjection' | 'pfizerInjection') => void} callback quand injectionVaccine change de valeur */ onInjectionVaccineChange(callback) { - this.onInjectionTypeCb = callback; + this.onInjectionVaccineCb = callback; } start() { @@ -187,6 +191,8 @@ class AppStatus { this.onAutoBookChangeCb(this.autoBook); this.injectionType = "fullServiceInjection"; this.onInjectionTypeCb(this.injectionType); + this.injectionVaccine = "modernaInjection"; + this.onInjectionTypeCb(this.injectionVaccine); } /** @@ -202,6 +208,7 @@ class AppStatus { this.onStoppedChangeCb = null; this.onAutoBookChangeCb = null; this.onInjectionTypeCb = null; + this.onInjectionVaccineCb = null; } /** @@ -249,5 +256,11 @@ class AppStatus { this.onInjectionTypeCb(this.injectionType); } + + if (change.injectionVaccine) { + this.injectionVaccine = change.injectionVaccine.newValue; + + this.onInjectionVaccineCb(this.injectionVaccine); + } } }