File tree 3 files changed +13
-13
lines changed
3 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export class CommentsPage {
24
24
this . load ( ) ;
25
25
}
26
26
27
- private load ( ) {
27
+ load ( ) {
28
28
this . redditApi . fetchComments ( this . post ) . subscribe ( ( comments ) => {
29
29
// comments.sort((a,b) => b.score - a.score);
30
30
this . comments = comments ;
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import { CommentsPage } from '../comments/comments'
12
12
providers : [ RedditApiService ]
13
13
} )
14
14
export class PostsPage {
15
- public loadCompleted : boolean = false ;
15
+ loadCompleted : boolean = false ;
16
16
17
17
posts : Array < any > ;
18
18
commentsPage = CommentsPage ;
@@ -21,27 +21,27 @@ export class PostsPage {
21
21
this . load ( ) ;
22
22
}
23
23
24
- private load ( ) : void {
24
+ load ( ) {
25
25
this . redditApi . fetchHot ( ) . subscribe ( ( posts ) => {
26
26
this . posts = posts ;
27
27
this . loadCompleted = true ;
28
28
console . log ( posts )
29
29
} )
30
30
}
31
31
32
- public getPostImage ( post ) {
32
+ getPostImage ( post ) {
33
33
let postImage = '' ;
34
34
if ( ! post . imageError && post . preview ) {
35
35
postImage = post . preview . images [ 0 ] . source . url ;
36
36
}
37
37
return postImage ;
38
38
}
39
39
40
- public setImageError ( post ) {
40
+ setImageError ( post ) {
41
41
post . imageError = true ;
42
42
}
43
43
44
- public readPost ( post ) {
44
+ readPost ( post ) {
45
45
let redditUrl = 'https://www.reddit.com/r/'
46
46
if ( post . url . includes ( redditUrl ) ) {
47
47
this . goToComments ( post )
@@ -50,11 +50,11 @@ export class PostsPage {
50
50
}
51
51
}
52
52
53
- public goToComments ( post ) {
53
+ goToComments ( post ) {
54
54
this . navCtrl . push ( this . commentsPage , { post : post } )
55
55
}
56
56
57
- public goToPost ( post ) {
57
+ goToPost ( post ) {
58
58
window . open ( post . url , '_blank' ) ;
59
59
}
60
60
Original file line number Diff line number Diff line change @@ -10,32 +10,32 @@ export class RedditApiService {
10
10
11
11
constructor ( public http : Http ) { }
12
12
13
- public fetchHot ( ) {
13
+ fetchHot ( ) {
14
14
return this . http . get ( BASE_URL + JSON_POSTFIX )
15
15
. map ( this . redditCollectionToJson )
16
16
}
17
17
18
- public fetchNext ( lastPostName : string ) {
18
+ fetchNext ( lastPostName : string ) {
19
19
return this . http . get ( BASE_URL + JSON_POSTFIX + '?count=' + 25 + '&after=' + lastPostName )
20
20
. map ( this . redditCollectionToJson )
21
21
}
22
22
23
- public fetchComments ( post ) {
23
+ fetchComments ( post ) {
24
24
let url : string = BASE_URL + post . permalink + JSON_POSTFIX ;
25
25
return this . http . get ( url )
26
26
. map ( res => res . json ( ) [ 1 ] . data . children . map ( c => c . data ) . filter ( c => c . body ) )
27
27
. map ( this . beautifyReplies . bind ( this ) )
28
28
}
29
29
30
- public beautifyReplies ( comments ) {
30
+ beautifyReplies ( comments ) {
31
31
return comments . map ( comment => {
32
32
comment . replies = comment . replies ? comment . replies . data . children . map ( reply => reply . data ) . filter ( c => c . body ) : [ ] ;
33
33
this . beautifyReplies ( comment . replies ) ;
34
34
return comment ;
35
35
} )
36
36
}
37
37
38
- private redditCollectionToJson ( response ) {
38
+ redditCollectionToJson ( response ) {
39
39
return response . json ( ) . data . children . map ( c => c . data )
40
40
}
41
41
}
You can’t perform that action at this time.
0 commit comments