@@ -26,8 +26,14 @@ function couple(x) {
2626export default class Root extends React . PureComponent {
2727 constructor ( props ) {
2828 super ( props ) ;
29- // this.state = { desc: "", id: "", changed: 0, timeremaining: 0};
30- this . state = { desc : "Codeforces Round #663 (Div. 2)" , id : 1176 , changed : 2 , timeremaining : 0 }
29+ // this.state = { desc: "", id: "", changed: 0, timeremaining: 0"};
30+ this . state = {
31+ desc : "Codeforces Round #663 (Div. 2)" ,
32+ id : 1391 ,
33+ changed : 2 ,
34+ timeremaining : 0 ,
35+ profimg : "//templates.joomla-monster.com/joomla30/jm-news-portal/components/com_djclassifieds/assets/images/default_profile.png"
36+ }
3137 }
3238
3339 fetch ( url ) {
@@ -118,12 +124,33 @@ export default class Root extends React.PureComponent {
118124 if ( event . target ) {
119125 this . setState ( { id : event . target . value } ) ;
120126 }
121- // console.log(this.state);
127+ }
128+
129+ fetchprofileimage ( ) {
130+ var url = "https://codeforces.com/api/user.info?handles=" + atom . config . get ( "codeblue.codeforcesHandle" )
131+ fetch ( url )
132+ . then ( res => res . json ( ) )
133+ . then ( res => this . setState ( { profimg : res . result [ 0 ] . titlePhoto } ) )
134+ . catch ( err => console . log ( "Error" ) ; )
135+ }
136+
137+ Loadprofile ( { profimg} ) {
138+ var handle = atom . config . get ( "codeblue.codeforcesHandle" )
139+ return (
140+ < div className = "profile" >
141+ < div className = "profile-image" >
142+ < img src = { "https:" + profimg } />
143+ </ div >
144+ < span > { handle } </ span >
145+ </ div >
146+ )
122147 }
123148
124149 render ( ) {
150+ this . fetchprofileimage ( )
125151 return (
126152 < div >
153+ < this . Loadprofile profimg = { this . state . profimg } />
127154 { this . state . changed ? < h2 > { this . state . desc } </ h2 > : null }
128155
129156 { this . state . changed == 0 ? (
0 commit comments