1
1
import * as angular from 'angular' ;
2
2
3
- import { ApiService } from '../api/api.service' ;
4
- import { JsonRpcCallback } from '../api/json-rpc.service' ;
5
- import { CommentsOfflineCacheService } from './comments-offline-cache.service' ;
3
+ import { ApiService } from '../api/api.service' ;
4
+ import { JsonRpcCallback , JsonRpcResult } from '../api/json-rpc.service' ;
5
+ import { CommentsOfflineCacheService } from './comments-offline-cache.service' ;
6
6
7
7
class Comment {
8
8
id : string ;
@@ -124,7 +124,7 @@ export class LexiconCommentService {
124
124
return 0 ;
125
125
}
126
126
127
- removeCommentFromLists ( commentId : string , replyId : string ) : void {
127
+ removeCommentFromLists = ( commentId : string , replyId : string ) : void => {
128
128
if ( replyId ) {
129
129
// just delete the replyId but don't delete the entire comment
130
130
LexiconCommentService . deleteCommentInList ( commentId , replyId , this . comments . items . all ) ;
@@ -149,35 +149,35 @@ export class LexiconCommentService {
149
149
arr . push . apply ( arr , this . $filter ( 'filter' ) ( comments , filter . byStatus ) ) ;
150
150
}
151
151
152
- update ( commentData : any , callback : JsonRpcCallback ) : void {
153
- this . api . call ( 'lex_comment_update' , [ commentData ] , callback ) ;
152
+ update ( commentData : any , callback : JsonRpcCallback ) : angular . IPromise < JsonRpcResult > {
153
+ return this . api . call ( 'lex_comment_update' , [ commentData ] , callback ) ;
154
154
}
155
155
156
- updateReply ( commentId : string , reply : string , callback : JsonRpcCallback ) : void {
156
+ updateReply ( commentId : string , reply : string , callback : JsonRpcCallback ) : angular . IPromise < JsonRpcResult > {
157
157
const comment = this . getCurrentEntryComment ( commentId ) ;
158
158
comment . replies . push ( reply ) ;
159
- this . api . call ( 'lex_commentReply_update' , [ commentId , reply ] , callback ) ;
159
+ return this . api . call ( 'lex_commentReply_update' , [ commentId , reply ] , callback ) ;
160
160
}
161
161
162
- remove ( commentId : string , callback : JsonRpcCallback ) : void {
163
- this . api . call ( 'lex_comment_delete' , [ commentId ] , callback ) ;
162
+ remove ( commentId : string , callback : JsonRpcCallback ) : angular . IPromise < JsonRpcResult > {
163
+ return this . api . call ( 'lex_comment_delete' , [ commentId ] , callback ) ;
164
164
}
165
165
166
- deleteReply ( commentId : string , replyId : string , callback : JsonRpcCallback ) : void {
167
- this . api . call ( 'lex_commentReply_delete' , [ commentId , replyId ] , callback ) ;
166
+ deleteReply ( commentId : string , replyId : string , callback : JsonRpcCallback ) : angular . IPromise < JsonRpcResult > {
167
+ return this . api . call ( 'lex_commentReply_delete' , [ commentId , replyId ] , callback ) ;
168
168
}
169
169
170
- plusOne ( commentId : string , callback : JsonRpcCallback ) : void {
170
+ plusOne ( commentId : string , callback : JsonRpcCallback ) : angular . IPromise < JsonRpcResult > {
171
171
const comment = this . getCurrentEntryComment ( commentId ) ;
172
172
comment . score ++ ;
173
173
this . comments . counts . userPlusOne [ commentId ] = 1 ;
174
- this . api . call ( 'lex_comment_plusOne' , [ commentId ] , callback ) ;
174
+ return this . api . call ( 'lex_comment_plusOne' , [ commentId ] , callback ) ;
175
175
}
176
176
177
- updateStatus ( commentId : string , status : string , callback : JsonRpcCallback ) : void {
177
+ updateStatus ( commentId : string , status : string , callback : JsonRpcCallback ) : angular . IPromise < JsonRpcResult > {
178
178
const comment = this . getCurrentEntryComment ( commentId ) ;
179
179
comment . status = status ;
180
- this . api . call ( 'lex_comment_updateStatus' , [ commentId , status ] , callback ) ;
180
+ return this . api . call ( 'lex_comment_updateStatus' , [ commentId , status ] , callback ) ;
181
181
}
182
182
183
183
private static deleteCommentInList ( commentId : string , replyId : string , commentsList : any ) : void {
0 commit comments