fix the acquisition callback
This commit is contained in:
		| @@ -73,12 +73,9 @@ async function getBahncardInfo() { | |||||||
| browser.storage.sync.get(["acquireAll","acquireBahncard"]).then(v => { | browser.storage.sync.get(["acquireAll","acquireBahncard"]).then(v => { | ||||||
|     if (v.acquireAll!=false){ |     if (v.acquireAll!=false){ | ||||||
|         Promise.all([getKundenkontoV2(), getBahncardInfo()]).then(data => { |         Promise.all([getKundenkontoV2(), getBahncardInfo()]).then(data => { | ||||||
|             const saveData = {...data[0], "bcnum": data[1]}; |             const saveData = {...data[0], "bcnum": data[1], "acquireAll": false}; | ||||||
|             console.info("Saving", saveData); |             console.info("Saving", saveData); | ||||||
|             browser.storage.sync.set(saveData).then(()=>{ |             browser.storage.sync.set(saveData).then(() => window.close()) | ||||||
|                 alert("Saved all available data to settings.\nPlease enter your bank details on the bottom of the settings page."); |  | ||||||
|                 window.close(); |  | ||||||
|             }) |  | ||||||
|         }) |         }) | ||||||
|     } |     } | ||||||
|     if (v.acquireBahncard != false) { // may also be undefined, so no identity check here |     if (v.acquireBahncard != false) { // may also be undefined, so no identity check here | ||||||
| @@ -86,10 +83,7 @@ browser.storage.sync.get(["acquireAll","acquireBahncard"]).then(v => { | |||||||
|             if (!!v && v.length == 16) { |             if (!!v && v.length == 16) { | ||||||
|                 const saveData = { "bcnum": v, "acquireBahncard": false } |                 const saveData = { "bcnum": v, "acquireBahncard": false } | ||||||
|                 console.info("Saving", saveData); |                 console.info("Saving", saveData); | ||||||
|                 browser.storage.sync.set(saveData).then(() => { |                 browser.storage.sync.set(saveData).then(() => window.close()); | ||||||
|                     alert("Saved your BahnCard number to settings.\nReload the settings page to continue.");  |  | ||||||
|                     window.close(); |  | ||||||
|                 }); |  | ||||||
|             } |             } | ||||||
|         }, f => console.error("Could not acquire BahnCard number.", f)) |         }, f => console.error("Could not acquire BahnCard number.", f)) | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -177,14 +177,12 @@ function startBcnumAcquisition(ev) { | |||||||
|   }) |   }) | ||||||
| } | } | ||||||
| function startAllAcquisition(ev) { | function startAllAcquisition(ev) { | ||||||
|   browser.storage.sync.set({"acquireAll":true}).then(() => { |   browser.storage.sync.set({ "acquireAll": true }).then(() => { | ||||||
|     browser.storage.sync.onChanged.addListener(changes => { |     browser.storage.sync.onChanged.addListener(changes => { | ||||||
|       console.debug(changes); |       console.debug(changes); | ||||||
|       for(const [key, changeSet] of Object.entries(changes)){ |       if ("acquireAll" in changes) { | ||||||
|         if (key === "acquireAll"){ |  | ||||||
|         document.location.reload(); |         document.location.reload(); | ||||||
|       } |       } | ||||||
|       } |  | ||||||
|     }) |     }) | ||||||
|     bahncardWindow = window.open("https://www.bahn.de/buchung/kundenkonto/bahncard", "_blank", "popup") |     bahncardWindow = window.open("https://www.bahn.de/buchung/kundenkonto/bahncard", "_blank", "popup") | ||||||
|     if (bahncardWindow instanceof Window) { |     if (bahncardWindow instanceof Window) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 iw0
					iw0