@@ -9,6 +9,7 @@ import { Input } from '../../components/input'
9
9
import InfiniteScroll from 'react-infinite-scroll-component'
10
10
import { renderMediaType } from '../../components/media-types'
11
11
import './style.css'
12
+ import { last } from 'lodash'
12
13
13
14
const axios = require ( 'axios' )
14
15
const ls = require ( 'local-storage' )
@@ -174,7 +175,7 @@ async function fetchGLB(offset) {
174
175
async function fetchInteractive ( offset ) {
175
176
const { errors, data } = await fetchGraphQL ( `
176
177
query InteractiveObjkts {
177
- hic_et_nunc_token(where: { mime: {_in : [ "application/x-directory" ]}, supply : { _neq : 0 } }, limit : 15, offset : ${ offset } , order_by: {id: desc}) {
178
+ hic_et_nunc_token(where: { mime: {_in : [ "application/x-directory", "image/svg+xml" ]}, supply : { _neq : 0 } }, limit : 15, offset : ${ offset } , order_by: {id: desc}) {
178
179
id
179
180
artifact_uri
180
181
display_uri
@@ -341,6 +342,7 @@ async function fetchRandomObjkts() {
341
342
}
342
343
343
344
async function fetchDay ( day , offset ) {
345
+ console . log ( day )
344
346
const { errors, data } = await fetchGraphQL ( `query dayTrades {
345
347
hic_et_nunc_trade(where: {timestamp: {_gte: "${ day } "}}, order_by: {swap: {price: desc}}, limit : 15, offset : ${ offset } ) {
346
348
timestamp
@@ -370,6 +372,38 @@ async function fetchDay(day, offset) {
370
372
371
373
}
372
374
375
+ async function fetchSales ( offset ) {
376
+ console . log ( offset )
377
+ const { errors, data } = await fetchGraphQL ( `
378
+ query sales {
379
+ hic_et_nunc_trade(order_by: {timestamp: desc}, limit : 15, offset : ${ offset } ) {
380
+ timestamp
381
+ swap {
382
+ price
383
+ }
384
+ token {
385
+ artifact_uri
386
+ display_uri
387
+ id
388
+ mime
389
+ }
390
+ }
391
+ }` , 'sales' , { } )
392
+
393
+ if ( errors ) {
394
+ console . log ( errors )
395
+ }
396
+
397
+ let result = [ ]
398
+
399
+ try {
400
+ result = data . hic_et_nunc_trade
401
+ } catch ( e ) { }
402
+
403
+ return result
404
+
405
+ }
406
+
373
407
async function fetchSubjkts ( subjkt ) {
374
408
//console.log(subjkt)
375
409
const { errors, data } = await fetchGraphQL ( `
@@ -464,6 +498,8 @@ async function fetchHdao(offset) {
464
498
return result
465
499
}
466
500
501
+
502
+
467
503
export class Search extends Component {
468
504
static contextType = HicetnuncContext
469
505
@@ -476,15 +512,17 @@ export class Search extends Component {
476
512
prev : '' ,
477
513
reset : false ,
478
514
flag : false ,
515
+ lastId : undefined ,
479
516
tags : [
480
517
{ id : 0 , value : '○' } ,
481
- { id : 1 , value : 'random' } ,
482
- { id : 2 , value : 'glb' } ,
483
- { id : 3 , value : 'music' } ,
484
- { id : 4 , value : 'interactive' } ,
485
- { id : 5 , value : 'gif' } ,
486
- { id : 6 , value : '1D' } ,
487
- { id : 7 , value : '1W' } ,
518
+ { id : 1 , value : 'latest sales' } ,
519
+ { id : 2 , value : 'latest mints' } ,
520
+ { id : 3 , value : 'glb' } ,
521
+ { id : 4 , value : 'music' } ,
522
+ { id : 5 , value : 'interactive' } ,
523
+ { id : 6 , value : 'gif' } ,
524
+ { id : 7 , value : '1D' } ,
525
+ { id : 8 , value : '1W' }
488
526
/* { id: 4, value: 'illustration' }, */
489
527
/* { id: 5, value: 'gif' } */
490
528
@@ -588,6 +626,19 @@ export class Search extends Component {
588
626
this . setState ( { feed : [ ...this . state . feed , ...( await fetchTag ( this . state . search , this . state . feed [ this . state . feed . length - 1 ] . id ) ) ] } )
589
627
}
590
628
629
+ if ( e == 'latest sales' ) {
630
+ let tokens = await fetchSales ( this . state . offset + 250 )
631
+ tokens = tokens . map ( e => e . token )
632
+ tokens = _ . uniqBy ( tokens , 'id' )
633
+
634
+ this . setState ( { feed : _ . uniqBy ( [ ...this . state . feed , ...tokens ] , 'id' ) } )
635
+ }
636
+
637
+ if ( e == 'latest mints' ) {
638
+ this . setState ( { feed : [ ...this . state . feed , ...( await fetchFeed ( 999999 || this . state . lastId ) ) ] } )
639
+ this . setState ( { lastId : Math . min . apply ( Math , this . state . feed . map ( e => e . id ) ) } )
640
+ }
641
+
591
642
this . setState ( { reset : false } )
592
643
593
644
//this.setState({ feed : this.state.feed })
0 commit comments