Show error to user when USw returns error

As we somehow forgot to add some basic metadata checks to the server, we've now enabled it and added some more errors. In such situations the errors should been shown to the user to understand what's happening.

Related USw commit: d4306f2f71
This commit is contained in:
Gusted 2021-07-18 02:28:47 +02:00
parent 8abcf9e754
commit a295d079b1
No known key found for this signature in database
GPG Key ID: FD821B732837125F
2 changed files with 12 additions and 2 deletions

View File

@ -372,7 +372,7 @@ const styleMan = (() => {
handleSave(await saveStyle(style), {reason: 'success-revoke', codeIsUpdated: true}); handleSave(await saveStyle(style), {reason: 'success-revoke', codeIsUpdated: true});
break; break;
case 'publish': case 'publish': {
if (!style._usw || !style._usw.token) { if (!style._usw || !style._usw.token) {
// Ensures just the style does have the _isUswLinked property as `true`. // Ensures just the style does have the _isUswLinked property as `true`.
for (const {style: someStyle} of dataMap.values()) { for (const {style: someStyle} of dataMap.values()) {
@ -406,8 +406,15 @@ const styleMan = (() => {
} }
handleSave(await saveStyle(style), {reason: 'success-publishing', codeIsUpdated: true}); handleSave(await saveStyle(style), {reason: 'success-publishing', codeIsUpdated: true});
} }
uploadStyle(style);
const returnResult = await uploadStyle(style);
// USw prefix errors with `Error:`.
if (returnResult.startsWith('Error:')) {
style._usw.publishingError = returnResult;
handleSave(await saveStyle(style), {reason: 'publishing-failed', codeIsUpdated: true});
}
break; break;
}
} }
}); });
} }

View File

@ -65,6 +65,9 @@ msg.onExtension(request => {
if (['success-publishing', 'success-revoke'].includes(request.reason)) { if (['success-publishing', 'success-revoke'].includes(request.reason)) {
updateUI(newStyle); updateUI(newStyle);
} }
if (request.reason === 'publishing-failed') {
messageBoxProxy.alert(`UserStyles.world returned error: ${newStyle._usw.publishingError}`);
}
}); });
} }
} }