Skip to content

Commit 174969a

Browse files
committed
Await provider init before adding toolbar buttons
1 parent 531de88 commit 174969a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/main.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import './style.css';
1717

1818
let gifProvider = new Klipy();
1919

20-
// Switch to GIPHY if the user has provided their own API key
21-
getSetting('giphyApiKey').then((key) => {
20+
async function initProvider() {
21+
const key = await getSetting('giphyApiKey');
2222
if (key) {
2323
gifProvider = new Giphy(key);
2424
}
25-
});
25+
}
2626

2727
// Debug mode is controlled by the DEBUG environment variable
2828
// Set with DEBUG=true npm run build
@@ -277,7 +277,8 @@ function addToolbarButton(toolbar) {
277277
* Initialize the extension by adding buttons to existing toolbars
278278
* and watching for new ones.
279279
*/
280-
function init() {
280+
async function init() {
281+
await initProvider();
281282
debugLog('Initializing GIFs for GitHub...');
282283

283284
// Add buttons to existing toolbars

0 commit comments

Comments
 (0)