aboutsummaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
authorAshm Walia <ashmwalia@outlook.com>2021-01-25 18:00:44 -0800
committerAshm Walia <ashmwalia@outlook.com>2021-01-25 18:00:44 -0800
commit755f4f540d3e759ff9ad3bc35c64b6f7fc83998b (patch)
tree6619de58ffcd0a5c9e32a612ffc82f0d65d041d9 /src/services
parent6cd49ed14f99fe953026e54969abc6232f3aec57 (diff)
Add provision to show and hide replies
Diffstat (limited to 'src/services')
-rw-r--r--src/services/MomentServices.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/services/MomentServices.ts b/src/services/MomentServices.ts
index 7bad6d4c..77740e7e 100644
--- a/src/services/MomentServices.ts
+++ b/src/services/MomentServices.ts
@@ -1,3 +1,4 @@
+import {CommentType} from './../types/types';
import AsyncStorage from '@react-native-community/async-storage';
import {Alert} from 'react-native';
import RNFetchBlob from 'rn-fetch-blob';
@@ -13,8 +14,8 @@ import {checkImageUploadStatus} from '../utils';
//Get all comments for a moment
export const getMomentComments = async (
momentId: string,
- callback: Function,
-) => {
+): Promise<CommentType[]> => {
+ let comments: CommentType[] = [];
try {
const token = await AsyncStorage.getItem('token');
const response = await fetch(COMMENTS_ENDPOINT + '?moment_id=' + momentId, {
@@ -25,14 +26,14 @@ export const getMomentComments = async (
});
const status = response.status;
if (status === 200) {
- const comments = await response.json();
- callback(comments);
+ comments = await response.json();
} else {
console.log('Could not load comments');
}
} catch (error) {
console.log('Could not load comments', error);
}
+ return comments;
};
export const postMomentComment = async (