File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5357,7 +5357,11 @@ <h2 id="work-title">${esc(item.title)}</h2>
53575357 piece . feelings = state . draft . feelings ;
53585358 piece . colour = state . draft . colour ;
53595359 piece . question = state . content . question ;
5360- const blob = await ( await fetch ( image ) ) . blob ( ) ;
5360+ // Decoded here, not fetched: the site's security policy only lets the page
5361+ // fetch from its own address, and a data: address is not that.
5362+ const [ head , encoded ] = image . split ( ',' ) ;
5363+ const bytes = Uint8Array . from ( atob ( encoded ) , ( c ) => c . charCodeAt ( 0 ) ) ;
5364+ const blob = new Blob ( [ bytes ] , { type : ( head . match ( / ^ d a t a : ( i m a g e \/ [ a - z ] + ) / ) || [ ] ) [ 1 ] || 'image/jpeg' } ) ;
53615365 await store . images . put ( piece . id , blob ) ;
53625366 piece . painter = 'model' ;
53635367 piece . seed = null ;
@@ -5465,7 +5469,17 @@ <h1 class="display-sm">Describe the picture.</h1>
54655469 artistMake ( ) ;
54665470 } ;
54675471 const keep = document . getElementById ( 'artist-keep' ) ;
5468- if ( keep ) keep . onclick = ( ) => artistKeep ( ) ;
5472+ if ( keep ) {
5473+ keep . onclick = async ( ) => {
5474+ keep . disabled = true ;
5475+ try {
5476+ await artistKeep ( ) ;
5477+ } catch {
5478+ artist . error = 'That painting could not be saved in this browser. It is still here; try again.' ;
5479+ render ( ) ;
5480+ }
5481+ } ;
5482+ }
54695483 }
54705484
54715485 return { html, mount } ;
You can’t perform that action at this time.
0 commit comments