Skip to content

Commit

Permalink
🐛 Fix issue with handling of clickSettingsBtn results
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonNastaly committed Jul 13, 2024
1 parent 24353b0 commit 5b15b43
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions entrypoints/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,9 @@ export default defineBackground({
target: {tabId: tabs[0].id, allFrames: true}, files: ['clickSettingsBtn.js'], injectImmediately: true,
});

// there should only be one non-null value, which from the frame where the actual notice is
const clickRetFrame = clickRet.find(ret => ret.result != null);
if (clickRetFrame == null) {
reject(new Error('clickResult of clickSettingsBtn was null'));
}
const clickResult = clickRetFrame.result;
if (clickResult.status === CLICK_BTN_STATUS.ERROR) {
reject(new Error(clickResult.data));
return;
} else if (clickResult.status === CLICK_BTN_STATUS.SUCCESS) {
const clickResults = clickRet.map(obj => obj.result);

if (clickResults.some(res => res?.status === CLICK_BTN_STATUS.SUCCESS)) {
await waitStableFrames(tabs[0].id);
let frameIds = await nonBlankFrameIds(tabs[0].id);
await browser.scripting.executeScript({
Expand Down Expand Up @@ -386,6 +379,11 @@ export default defineBackground({
} = await handleNewNotice(ieClassifier, twoLevelInteractiveElements, iElement, USE_QUANTIZED));
}
}
} else if (clickResults.some(res => res?.status === CLICK_BTN_STATUS.ERROR)) {
reject(new Error(clickResults.find(res => res?.status === CLICK_BTN_STATUS.ERROR).data));
return;
} else {
reject(new Error('no clickResult was success or result'));
}

// reset cookies and reload page
Expand Down

0 comments on commit 5b15b43

Please sign in to comment.