Show error to user when USw returns error (#1286)
Related USw commit: d4306f2f71
Co-authored-by: tophf <tophf@gmx.com>
			
			
This commit is contained in:
		
							parent
							
								
									8abcf9e754
								
							
						
					
					
						commit
						69ccdb0591
					
				|  | @ -372,7 +372,7 @@ const styleMan = (() => { | |||
|           handleSave(await saveStyle(style), {reason: 'success-revoke', codeIsUpdated: true}); | ||||
|           break; | ||||
| 
 | ||||
|         case 'publish': | ||||
|         case 'publish': { | ||||
|           if (!style._usw || !style._usw.token) { | ||||
|             // Ensures just the style does have the _isUswLinked property as `true`.
 | ||||
|             for (const {style: someStyle} of dataMap.values()) { | ||||
|  | @ -406,9 +406,16 @@ const styleMan = (() => { | |||
|             } | ||||
|             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; | ||||
|         } | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|  |  | |||
|  | @ -65,6 +65,10 @@ msg.onExtension(request => { | |||
|               if (['success-publishing', 'success-revoke'].includes(request.reason)) { | ||||
|                 updateUI(newStyle); | ||||
|               } | ||||
|               if (request.reason === 'publishing-failed') { | ||||
|                 messageBoxProxy.alert(newStyle._usw.publishingError, 'pre', | ||||
|                   'UserStyles.world: ' + t('genericError')); | ||||
|               } | ||||
|             }); | ||||
|         } | ||||
|       } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user