Skip to content

Commit

Permalink
refactor: Remove non-null assertion from inlineDisable
Browse files Browse the repository at this point in the history
Saved the value to a variable (tabId) before checking explicitly if it was undefined and change loop structure for cleaner code
  • Loading branch information
ChinoUkaegbu authored Aug 18, 2024
1 parent 8fd4bf4 commit 358eb60
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions extension/rikaichan.ts
Original file line number Diff line number Diff line change
@@ -209,16 +209,17 @@ class RcxMain {

// Send a disable message to all browsers
chrome.windows.getAll({ populate: true }, (windows) => {
for (let i = 0; i < windows.length; ++i) {
const tabs = windows[i].tabs;
for (const window of windows) {
const tabs = window.tabs;

Check warning on line 213 in extension/rikaichan.ts

Codecov / codecov/patch

extension/rikaichan.ts#L212-L213

Added lines #L212 - L213 were not covered by tests
if (tabs === undefined) {
continue;
}
for (let j = 0; j < tabs.length; ++j) {
if (tabs[j].id === undefined) {
for (const tab of tabs) {
const tabId = tab.id;
if (tabId === undefined) {

Check warning on line 219 in extension/rikaichan.ts

Codecov / codecov/patch

extension/rikaichan.ts#L217-L219

Added lines #L217 - L219 were not covered by tests
continue;
}
chrome.tabs.sendMessage(tabs[j].id!, { type: 'disable' });
chrome.tabs.sendMessage(tabId, { type: 'disable' });

Check warning on line 222 in extension/rikaichan.ts

Codecov / codecov/patch

extension/rikaichan.ts#L222

Added line #L222 was not covered by tests
}
}
});

0 comments on commit 358eb60

Please sign in to comment.