Skip to content

Commit

Permalink
Preserve shortcut for upcoming removal of default (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Mar 16, 2023
1 parent 4ce905b commit 4ecdfe8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions source/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ function handleMessages({code, count}, {tab}) {
}
}

// Temporary code from https://github.com/fregante/GhostText/pull/267
async function saveShortcut() {
const storage = await browser.storage.local.get('shortcut');
if (storage.shortcut) {
// Already saved
return;
}

const shortcuts = await browser.commands.getAll();
for (const item of shortcuts) {
if (item.shortcut) {
// eslint-disable-next-line no-await-in-loop -- Intentional
await browser.storage.local.set({shortcut: item.shortcut});
return;
}
}
}

function init() {
chrome.browserAction.onClicked.addListener(handleAction);
chrome.runtime.onMessage.addListener(handleMessages);
Expand Down Expand Up @@ -153,6 +171,8 @@ function init() {
});
}
});

saveShortcut();
}

init();

0 comments on commit 4ecdfe8

Please sign in to comment.