show installation error inline, allow retrying

This commit is contained in:
tophf 2021-08-12 10:05:37 +03:00
parent 91324a4a48
commit 5453ce54c0
2 changed files with 21 additions and 1 deletions

View File

@ -228,6 +228,24 @@ body.search-results-shown {
cursor: help;
}
[data-error] {
border: var(--pad) solid red;
border-radius: var(--pad);
padding: 0;
}
[data-error]::after {
content: attr(data-error);
display: block;
background: red;
color: yellow;
font-weight: bold;
padding-top: var(--pad);
hyphens: auto;
}
[data-error] .search-result-description {
display: none;
}
.search-results-nav {
flex-direction: row;
text-align: center;

View File

@ -412,6 +412,7 @@
saveScrollPosition(entry);
installButton.disabled = true;
entry.style.setProperty('pointer-events', 'none', 'important');
delete entry.dataset.error;
if (!isUsw) {
// FIXME: move this to background page and create an API like installUSOStyle
result.pingbackTimer = setTimeout(download, PINGBACK_DELAY,
@ -425,7 +426,8 @@
const style = await API.usercss.install({sourceCode, updateUrl});
renderFullInfo(entry, style);
} catch (reason) {
error(`Error while downloading usoID:${id}\nReason: ${reason}`);
entry.dataset.error = `${t('genericError')}: ${reason}`;
entry.scrollIntoView({behavior: 'smooth', block: 'nearest'});
}
$remove('.lds-spinner', entry);
installButton.disabled = false;