From 358eb609cc86a0dfc81ab106549c8bdb581b6e76 Mon Sep 17 00:00:00 2001 From: ChinoUkaegbu <77782533+ChinoUkaegbu@users.noreply.github.com> Date: Sun, 18 Aug 2024 13:30:40 +0400 Subject: [PATCH] refactor: Remove non-null assertion from inlineDisable Saved the value to a variable (tabId) before checking explicitly if it was undefined and change loop structure for cleaner code --- extension/rikaichan.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/extension/rikaichan.ts b/extension/rikaichan.ts index 7822fb2c3..a049bffed 100644 --- a/extension/rikaichan.ts +++ b/extension/rikaichan.ts @@ -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; 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) { continue; } - chrome.tabs.sendMessage(tabs[j].id!, { type: 'disable' }); + chrome.tabs.sendMessage(tabId, { type: 'disable' }); } } });