fix the acquisition callback

This commit is contained in:
iw0 2024-05-29 13:53:23 +02:00
parent de690f43a3
commit 5dda9e52d9
2 changed files with 6 additions and 14 deletions

View File

@ -73,12 +73,9 @@ async function getBahncardInfo() {
browser.storage.sync.get(["acquireAll","acquireBahncard"]).then(v => {
if (v.acquireAll!=false){
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);
browser.storage.sync.set(saveData).then(()=>{
alert("Saved all available data to settings.\nPlease enter your bank details on the bottom of the settings page.");
window.close();
})
browser.storage.sync.set(saveData).then(() => window.close())
})
}
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) {
const saveData = { "bcnum": v, "acquireBahncard": false }
console.info("Saving", saveData);
browser.storage.sync.set(saveData).then(() => {
alert("Saved your BahnCard number to settings.\nReload the settings page to continue.");
window.close();
});
browser.storage.sync.set(saveData).then(() => window.close());
}
}, f => console.error("Could not acquire BahnCard number.", f))
}

View File

@ -180,11 +180,9 @@ function startAllAcquisition(ev) {
browser.storage.sync.set({ "acquireAll": true }).then(() => {
browser.storage.sync.onChanged.addListener(changes => {
console.debug(changes);
for(const [key, changeSet] of Object.entries(changes)){
if (key === "acquireAll"){
if ("acquireAll" in changes) {
document.location.reload();
}
}
})
bahncardWindow = window.open("https://www.bahn.de/buchung/kundenkonto/bahncard", "_blank", "popup")
if (bahncardWindow instanceof Window) {