Address code review comments for #2758

- Use `commands.reset` insead of `commands.update`
- Do not swallow errors
This commit is contained in:
Stephen Thompson 2025-04-29 16:36:19 -04:00
parent e96b275e02
commit f1a24ed6fb

View file

@ -52,23 +52,19 @@ const backgroundLogic = {
* *
* @param {{reason: runtime.OnInstalledReason, previousVersion?: string}} details * @param {{reason: runtime.OnInstalledReason, previousVersion?: string}} details
*/ */
_undoDefault820SortTabsKeyboardShortcut(details) { async _undoDefault820SortTabsKeyboardShortcut(details) {
if (details.reason === "update" && details.previousVersion === "8.2.0") { if (details.reason === "update" && details.previousVersion === "8.2.0") {
browser.commands.getAll().then((commands) => { const commands = await browser.commands.getAll();
const sortTabsCommand = commands.find(command => command.name === "sort_tabs"); const sortTabsCommand = commands.find(command => command.name === "sort_tabs");
if (sortTabsCommand) { if (sortTabsCommand) {
const previouslySuggestedKeys = [ const previouslySuggestedKeys = [
"Ctrl+Comma", // "default" "Ctrl+Comma", // "default"
"MacCtrl+Comma", // "mac" "MacCtrl+Comma", // "mac"
]; ];
if (previouslySuggestedKeys.includes(sortTabsCommand.shortcut)) { if (previouslySuggestedKeys.includes(sortTabsCommand.shortcut)) {
browser.commands.update({ browser.commands.reset("sort_tabs");
name: "sort_tabs",
shortcut: "",
});
}
} }
}).catch(err => console.error(err)); }
} }
}, },