deezer: wait for toolbar to appear

This commit is contained in:
Bao Trinh 2023-01-11 11:47:52 -06:00 committed by Aurélien Mino
parent 6be127759f
commit 2cb8763139

View file

@ -128,6 +128,16 @@ function parseDeezerRelease(releaseUrl, data) {
return release;
}
function waitForEl(selector, callback) {
if (jQuery(selector).length) {
callback();
} else {
setTimeout(function () {
waitForEl(selector, callback);
}, 100);
}
}
function insertLink(release, release_url) {
let editNote = MBImport.makeEditNote(release_url, 'Deezer');
let parameters = MBImport.buildFormParameters(release, editNote);
@ -139,7 +149,8 @@ function insertLink(release, release_url) {
${MBImport.buildSearchButton(release)}
</div>`
).hide();
$('[data-testid="toolbar"]').append(mbUI);
mbUI.show();
waitForEl('[data-testid="toolbar"]', function () {
$('[data-testid="toolbar"]').append(mbUI);
mbUI.show();
});
}