From b5ecbf3e421e9e6f1dbab9f3f851d265ae8470c6 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 14 Dec 2020 19:22:35 -0500 Subject: [TMA-406&201] User Handle UI for Individual Moments (#129) * initial work * made big progress towards flatlist moment view * UI done, just need to pass in data now * minor fixes to get things actually running correctly * vertical scroll working * initial index working * moment drawer text color to red * moved report to drawer * removed garbage * added ? --- src/services/MomentServices.ts | 2 +- src/services/ReportingService.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/services') diff --git a/src/services/MomentServices.ts b/src/services/MomentServices.ts index ed868582..96643bc3 100644 --- a/src/services/MomentServices.ts +++ b/src/services/MomentServices.ts @@ -69,9 +69,9 @@ export const postMomentComment = async ( export const getMomentCommentsCount = async ( momentId: string, callback: Function, - token: string, ) => { try { + const token = await AsyncStorage.getItem('token'); const response = await fetch(COMMENTS_ENDPOINT + `${momentId}/`, { method: 'GET', headers: { diff --git a/src/services/ReportingService.ts b/src/services/ReportingService.ts index 2650a703..1563d086 100644 --- a/src/services/ReportingService.ts +++ b/src/services/ReportingService.ts @@ -2,14 +2,15 @@ import {REPORT_ISSUE_ENDPOINT} from '../constants'; import {Alert} from 'react-native'; +import AsyncStorage from '@react-native-community/async-storage'; export const sendReport = async ( moment_id: string, message: string, - token: string, - callback: Function, + callback?: Function, ) => { try { + let token = await AsyncStorage.getItem('token'); let response = await fetch(REPORT_ISSUE_ENDPOINT, { method: 'POST', body: JSON.stringify({ @@ -28,7 +29,9 @@ export const sendReport = async ( } else { Alert.alert('Something went wrong!', 'Please try again.'); } - callback(false); + if (callback) { + callback(); + } } catch (error) { Alert.alert('Something went wrong!', 'Please try again.'); console.log( -- cgit v1.2.3-70-g09d2