- Android
- iOS
- JavaScript
- Flutter
- ReactNative
Get the comment list for a Moment. Pagination before or after a specified time is supported.
GetMomentCommentOption Structure
| Name | Type | Description | Version |
|---|---|---|---|
| momentId | String | Moment ID | 1.8.30 |
| count | int | Retrieve the specified number of comments, up to 20 records per request | 1.8.30 |
| direction | JIMConst.PullDirection | Retrieval direction. Use startTime to retrieve older or newer comments. | 1.8.30 |
| startTime | long | Start time for retrieving comments. Use with direction; 0 uses the current time. | 1.8.30 |
API Reference
/**
* get the comment list
* @param option retrieval options
* @param callback result callback
*/
void getCommentList(GetMomentCommentOption option, JIMConst.IResultListCallback<MomentComment> callback);
Code Example
GetMomentCommentOption o = new GetMomentCommentOption();
o.setCount(20);
o.setDirection(JIMConst.PullDirection.OLDER);
o.setMomentId("momentId");
JIM.getInstance().getMomentManager().getCommentList(o, new JIMConst.IResultListCallback<MomentComment>() {
@Override
public void onSuccess(List<MomentComment> data, boolean isFinish) {
}
@Override
public void onError(int errorCode) {
}
});
Get the comment list for a Moment. Pagination before or after a specified time is supported.
JGetMomentCommentOption Structure
| Name | Type | Description | Version |
|---|---|---|---|
| momentId | NSString | Moment ID | 1.8.30 |
| count | int | Retrieve the specified number of comments, up to 20 records per request | 1.8.30 |
| direction | JPullDirection | Retrieval direction. Use startTime to retrieve older or newer comments. | 1.8.30 |
| startTime | long long | Start time for retrieving comments. Use with direction; 0 uses the current time. | 1.8.30 |
API Reference
/// get the comment list
/// - Parameters:
/// - option: retrieval options
/// - completeBlock: result callback
- (void)getCommentList:(nonnull JGetMomentCommentOption *)option
complete:(nullable void (^)(JErrorCode errorCode, NSArray <JMomentComment *> * _Nullable commentList, BOOL isFinish))completeBlock;
Code Example
JGetMomentCommentOption *o = [[JGetMomentCommentOption alloc] init];
o.momentId = @"momentId";
o.count = 10;
o.direction = JPullDirectionOlder;
[JIM.shared.momentManager getCommentList:o
complete:^(JErrorCode errorCode, NSArray<JMomentComment *> * _Nullable commentList, BOOL isFinish) {
}];
Get the comment list for a Moment. Pagination before or after a specified time is supported.
GetMomentCommentOption Structure
| Name | Type | Default | Description | Version |
|---|---|---|---|---|
| momentId | String | '' | Moment ID | 0.0.66 |
| count | int | 10 | Retrieve the specified number of comments, up to 20 records per request | 0.0.66 |
| direction | int | 1 | Retrieval direction (0 for newer records and 1 for older records). Use startTime to retrieve older or newer comments. | 0.0.66 |
| startTime | int | 0 | Start time for retrieving comments. Use with direction; 0 uses the current time. | 0.0.66 |
API Reference
/**
* get the comment list
* @param o retrieval options
* return comment list
*/
Future<ResultHasMore<List<MomentComment>>> getMomentCommentList(GetMomentCommentOption o) async
Code Example
GetMomentCommentOption commentOption = GetMomentCommentOption();
commentOption.momentId = 'momentId';
ResultHasMore<List<MomentComment>> commentList = await JuggleIm.instance.getMomentCommentList(commentOption);
Get the comment list for a Moment. Pagination before or after a specified time is supported.
GetMomentCommentOption Structure
| Name | Type | Default | Description | Version |
|---|---|---|---|---|
| momentId | string | '' | Moment ID | - |
| count | number | 10 | Retrieve the specified number of comments, up to 20 records per request | - |
| direction | number | 1 | Retrieval direction (0 for newer records and 1 for older records). Use startTime to retrieve older or newer comments. | - |
| startTime | number | 0 | Start time for retrieving comments. Use with direction; 0 uses the current time. | - |
API Reference
/**
* get the comment list
* @param option retrieval options
* return Promise<{ list: MomentComment[], isFinished: boolean }>
*/
getCommentList(option: GetMomentCommentOption): Promise<{ list: MomentComment[], isFinished: boolean }>
Code Example
import { JuggleIMMoment } from 'juggleim-rnsdk';
const commentOption = {
momentId: 'momentId',
};
const commentList = await JuggleIMMoment.getCommentList(commentOption);
Get the comment list for a Moment. Pagination before or after a specified time is supported.
Parameters
| Name | Type | Required | Default | Description | Version |
|---|---|---|---|---|---|
| option | Object | No | 1.9.6 | ||
| option.count | Number | No | 50 | Retrieve the specified number of comments, up to 20 records per request | 1.9.6 |
| option.order | Number | No | Retrieval direction | Retrieval direction. Use time to retrieve older or newer comments. | 1.9.6 |
| option.time | Number | No | 0 | Start time for retrieving comments. Use with order. | 1.9.6 |
Callback Parameters
| Property | Type | Description | Version |
|---|---|---|---|
| result | Object | Query result | 1.9.6 |
| result.comments | Array | Comments array. See the Comment | 1.9.6 |
| result.isFinished | Boolean | Whether retrieval is complete | 1.9.6 |
Code Example
/*
Assume the current user has 79 comments. Fetch 20 per page and sort the comment list by time in descending order. Use the following pagination logic:
1. Page 1 retrieval options: { count: 20, time: 0 }
2. Page 2 retrieval options: { count: 20, time: 'the smallest commentTime in the page 1 comment array' }
3. Page 3 retrieval options: { count: 20, time: 'the smallest commentTime in the page 2 comment array' }
4. Page 4 retrieval options: { count: 20, time: 'the smallest commentTime in the page 3 comment array' }
5. Finish: Stop loading when isFinished returns true
*/
jim.getComments().then((result) => {
let { comments, isFinished } = result;
console.log(isFinished, comments);
})