Skip to content

Commit

Permalink
Fix results saving
Browse files Browse the repository at this point in the history
  • Loading branch information
blokhin committed Jun 29, 2024
1 parent 6481c9f commit 060dc6a
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions app/app.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ namespace $.$$ {
const structure = JSON.stringify( this.fetch_by_number( number ) )
const params = new URLSearchParams({ structure })
const url = `https://labs.mpds.io/predict?${ params.toString() }`

const prediction = this.$.$mol_wire_sync( this ).$.$mol_fetch.success( url, {
method: 'post',
} ).json() ?? {} as any

return prediction
}

Expand All @@ -34,7 +34,7 @@ namespace $.$$ {
let str = json?.data[ 0 ]?.attributes?.chemical_formula_reduced
return formula_html( str )
}

@ $mol_mem_key
card_loaded( n: number ) {
try {
Expand All @@ -48,7 +48,7 @@ namespace $.$$ {

cards(): readonly ( any )[] {
const swiped = this.number_swiped()
return [
return [
this.Card( this.number_prefetch() ),
... swiped ? [ this.Card( swiped ) ] : [],
this.Card( this.number() ),
Expand Down Expand Up @@ -123,27 +123,30 @@ namespace $.$$ {

@ $mol_mem_key
swiped_to( id: number, next?: string ) {

const vote = next == 'left' ? 0 : next == 'right' ? 1 : undefined
if( vote !== undefined ) {

this.update()

const params = new URLSearchParams( {
id: this.json()?.data[ 0 ]?.attributes?._gnome_material_id,
comment: this.why( id ),
vote
} )

this.$.$mol_fetch.success( 'https://crus.absolidix.com', {
method: 'post',
headers: {
"Content-Type": "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
body: JSON.stringify( {
id, comment: this.why( id ), vote
} ),
body: params.toString(),
} )

}

return next ?? ''
}

}

function random_int( min: number, max: number ) {
Expand All @@ -170,5 +173,5 @@ namespace $.$$ {
if( sub ) html += '</sub>'
return html ?? ''
}

}

0 comments on commit 060dc6a

Please sign in to comment.