@@ -540,7 +540,8 @@ export class Search extends Component {
540
540
{ id : 7 , value : 'recent sales' } ,
541
541
{ id : 8 , value : '1D' } ,
542
542
{ id : 9 , value : '1W' } ,
543
- { id : 10 , value : '1M' }
543
+ { id : 10 , value : '1M' } ,
544
+ { id : 11 , value : 'ATH' }
544
545
] ,
545
546
select : [ ] ,
546
547
mouse : false ,
@@ -561,7 +562,7 @@ export class Search extends Component {
561
562
handleChange = ( e ) => {
562
563
this . setState ( { [ e . target . name ] : e . target . value } )
563
564
564
- if ( this . state . search . length >= 1 ) this . search ( )
565
+ // if (this.state.search.length >= 1) this.search()
565
566
}
566
567
567
568
update = async ( e , reset ) => {
@@ -609,6 +610,17 @@ export class Search extends Component {
609
610
} )
610
611
}
611
612
613
+ if ( e === 'ATH' ) {
614
+ let list = await fetchDay ( new Date ( '2021-05-01' ) . toISOString ( ) , this . state . offset )
615
+ list = list . map ( e => e . token )
616
+ list = [ ...this . state . feed , ...( list ) ]
617
+ list = _ . uniqBy ( list , 'id' )
618
+ console . log ( 'ath' , list )
619
+ this . setState ( {
620
+ feed : list
621
+ } )
622
+ }
623
+
612
624
if ( e === 'num' ) {
613
625
let res = await fetchFeed ( Number ( this . state . search ) + 1 - this . state . offset )
614
626
res = res . filter ( e => ! arr . includes ( e . creator_id ) )
@@ -693,92 +705,97 @@ export class Search extends Component {
693
705
let restricted = await getRestrictedAddresses ( )
694
706
result = _ . uniqBy ( [ ...this . state . feed , ...result ] , 'creator_id' )
695
707
result = result . filter ( e => ! restricted . includes ( e . creator_id ) )
696
- this . setState ( { feed : [ ...result ] , flag : true } )
708
+ this . setState ( { feed : [ ...result ] , flag : true } )
697
709
}
698
710
699
711
700
712
search = async ( e ) => {
701
713
714
+ console . log ( e )
715
+
702
716
this . setState ( { items : [ ] , feed : [ ] , search : e } )
703
717
this . setState ( { subjkt : await fetchSubjkts ( this . state . search ) } )
704
718
705
- if ( ( this . state . subjkt [ 0 ] ?. hdao_balance > 30000000 ) || ( isFloat ( Number ( this . state . search ) ) ) ) {
706
- console . log ( isFloat ( Number ( this . state . search ) ) )
707
- this . setState ( { feed : await fetchCreations ( this . state . subjkt [ 0 ] . address , this . state . offset ) , select : 'creations' } )
708
- } else if ( ! isNaN ( this . state . search ) ) {
719
+ if ( ! isNaN ( this . state . search ) ) {
709
720
this . setState ( { feed : await fetchFeed ( Number ( this . state . search ) + 1 ) , select : 'num' } )
710
721
} else {
711
722
this . setState ( { feed : _ . uniqBy ( await fetchTag ( this . state . search . toLowerCase ( ) , 9999999 ) , 'creator_id' ) , select : 'tag' } )
712
723
}
713
724
725
+
726
+ console . log ( this . state . feed )
714
727
}
715
728
716
- hoverState = ( bool ) => this . setState ( { mouse : bool } )
729
+ hoverState = ( bool ) => this . setState ( { mouse : bool } )
717
730
718
- select = ( id ) => this . setState ( { select : [ ...this . state . select , id ] } )
731
+ select = ( id ) => this . setState ( { select : [ ...this . state . select , id ] } )
719
732
720
- loadMore = ( ) => {
721
- this . setState ( { offset : this . state . offset + 15 } )
722
- this . update ( this . state . select , false )
723
- }
733
+ loadMore = ( ) => {
734
+ this . setState ( { offset : this . state . offset + 15 } )
735
+ this . update ( this . state . select , false )
736
+ }
724
737
725
- render ( ) {
738
+ handleKey = ( e ) => {
739
+ console . log ( this . state . search )
740
+ if ( e . key == 'Enter' ) this . search ( this . state . search )
741
+ }
726
742
727
- return (
728
- < Page >
729
- < Container >
730
- < Padding >
731
- < Input
732
- type = "text"
733
- name = "search"
734
- onMouseEnter = { ( ) => this . hoverState ( true ) }
735
- onMouseLeave = { ( ) => this . hoverState ( false ) }
736
- onChange = { e => this . search ( e . target . value ) }
737
- label = "objkt id, artists, tags"
738
- placeholder = "objkt id, artists, tags"
739
- />
740
- {
741
- < div style = { { marginTop : '15px' } } >
742
- { this . state . tags . map ( e => < a className = 'tag' href = '#' onClick = { ( ) => {
743
- this . update ( e . value , true )
744
- } } > { e . value } </ a > ) }
745
- </ div >
746
- }
747
- {
748
- ( this . state . subjkt . length > 0 ) && ( this . state . search !== "" ) ?
749
- < div style = { { maxHeight : '200px' , overflow : 'scroll' } } >
750
- {
751
- this . state . subjkt . map ( e => < div style = { { marginTop : '10px' } } > < a href = { `/${ e . name } ` } > { e . name } </ a > { e . metadata . description } </ div > )
752
- }
743
+ render ( ) {
744
+
745
+ return (
746
+ < Page >
747
+ < Container >
748
+ < Padding >
749
+ < Input
750
+ type = "text"
751
+ name = "search"
752
+ onChange = { this . handleChange }
753
+ label = "search objkt id, artists, tags (press Enter)"
754
+ placeholder = "search objkt id, artists, tags (press Enter)"
755
+ onKeyPress = { this . handleKey }
756
+ />
757
+ {
758
+ < div style = { { marginTop : '15px' } } >
759
+ { this . state . tags . map ( e => < a className = 'tag' href = '#' onClick = { ( ) => {
760
+ this . update ( e . value , true )
761
+ } } > { e . value } </ a > ) }
753
762
</ div >
763
+ }
764
+ {
765
+ ( this . state . subjkt . length > 0 ) && ( this . state . search !== "" ) ?
766
+ < div style = { { maxHeight : '200px' , overflow : 'scroll' } } >
767
+ {
768
+ this . state . subjkt . map ( e => < div style = { { marginTop : '10px' } } > < a href = { `/${ e . name } ` } > { e . name } </ a > { e . metadata . description } </ div > )
769
+ }
770
+ </ div >
771
+ :
772
+ undefined
773
+ }
774
+ </ Padding >
775
+ </ Container >
776
+ < Container xlarge >
777
+ {
778
+ this . state . feed . length > 0 ?
779
+ < InfiniteScroll
780
+ dataLength = { this . state . feed . length }
781
+ next = { this . loadMore }
782
+ hasMore = { this . state . hasMore }
783
+ loader = { undefined }
784
+ endMessage = { undefined }
785
+ >
786
+ < Container >
787
+ < Padding >
788
+ { this . state . feed . map ( ( item , index ) => (
789
+ < FeedItem key = { `${ item . id } -${ index } ` } { ...item } />
790
+ ) ) }
791
+ </ Padding >
792
+ </ Container >
793
+ </ InfiniteScroll >
754
794
:
755
795
undefined
756
796
}
757
- </ Padding >
758
- </ Container >
759
- < Container xlarge >
760
- {
761
- this . state . feed . length > 0 ?
762
- < InfiniteScroll
763
- dataLength = { this . state . feed . length }
764
- next = { this . loadMore }
765
- hasMore = { this . state . hasMore }
766
- loader = { undefined }
767
- endMessage = { undefined }
768
- >
769
- < Container >
770
- < Padding >
771
- { this . state . feed . map ( ( item , index ) => (
772
- < FeedItem key = { `${ item . id } -${ index } ` } { ...item } />
773
- ) ) }
774
- </ Padding >
775
- </ Container >
776
- </ InfiniteScroll >
777
- :
778
- undefined
779
- }
780
- </ Container >
781
- </ Page >
782
- )
797
+ </ Container >
798
+ </ Page >
799
+ )
800
+ }
783
801
}
784
- }
0 commit comments