aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-07-09 01:38:04 -0400
committerIvan Chen <ivan@tagg.id>2021-07-09 15:56:47 -0400
commit74d0ad5bab6f0d058fc03095fa0a313499162579 (patch)
tree2ca74c704d6d7d4693338ff84df747d7884c0771 /src
parentf78bb9fea2128825d9c9cf4a64a7b78a288250b1 (diff)
Lint, Update service code to allow category edition
Diffstat (limited to 'src')
-rw-r--r--src/components/comments/ZoomInCropper.tsx3
-rw-r--r--src/components/profile/MomentMoreInfoDrawer.tsx1
-rw-r--r--src/screens/profile/CaptionScreen.tsx19
-rw-r--r--src/services/MomentService.ts4
4 files changed, 15 insertions, 12 deletions
diff --git a/src/components/comments/ZoomInCropper.tsx b/src/components/comments/ZoomInCropper.tsx
index 6f2d7c21..8b87d137 100644
--- a/src/components/comments/ZoomInCropper.tsx
+++ b/src/components/comments/ZoomInCropper.tsx
@@ -1,7 +1,6 @@
import {RouteProp} from '@react-navigation/core';
-import {useFocusEffect} from '@react-navigation/native';
import {StackNavigationProp} from '@react-navigation/stack';
-import React, {useCallback, useEffect, useState} from 'react';
+import React, {useEffect, useState} from 'react';
import {Image, StyleSheet, TouchableOpacity} from 'react-native';
import {normalize} from 'react-native-elements';
import ImageZoom, {IOnMove} from 'react-native-image-pan-zoom';
diff --git a/src/components/profile/MomentMoreInfoDrawer.tsx b/src/components/profile/MomentMoreInfoDrawer.tsx
index 910aa095..493f6238 100644
--- a/src/components/profile/MomentMoreInfoDrawer.tsx
+++ b/src/components/profile/MomentMoreInfoDrawer.tsx
@@ -129,6 +129,7 @@ const MomentMoreInfoDrawer: React.FC<MomentMoreInfoDrawerProps> = (props) => {
screenType: screenType,
selectedTags: tags,
moment: moment,
+ selectedCategory: moment.moment_category,
});
};
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx
index 15566555..9a1878aa 100644
--- a/src/screens/profile/CaptionScreen.tsx
+++ b/src/screens/profile/CaptionScreen.tsx
@@ -20,13 +20,12 @@ import {useDispatch, useSelector} from 'react-redux';
import FrontArrow from '../../assets/icons/front-arrow.svg';
import {
MentionInputControlled,
- MomentPostButton,
SearchBackground,
TaggSquareButton,
} from '../../components';
import {CaptionScreenHeader} from '../../components/';
import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator';
-import {TAGG_LIGHT_BLUE, TAGG_LIGHT_BLUE_2} from '../../constants';
+import {TAGG_LIGHT_BLUE_2} from '../../constants';
import {
ERROR_NO_MOMENT_CATEGORY,
ERROR_SOMETHING_WENT_WRONG_REFRESH,
@@ -66,7 +65,8 @@ interface CaptionScreenProps {
}
const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
- const {screenType, moment} = route.params;
+ // moment is only present when editing
+ const {moment} = route.params;
const {
user: {userId},
} = useSelector((state: RootState) => state.user);
@@ -205,12 +205,13 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
handleSuccess();
};
- const handleDoneEditing = async () => {
+ const handleSubmitEditChanges = async () => {
setLoading(true);
- if (moment?.moment_id) {
+ if (moment?.moment_id && momentCategory) {
const success = await patchMoment(
moment.moment_id,
caption,
+ momentCategory,
formattedTags(),
);
if (success) {
@@ -315,8 +316,8 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
/>
{momentCategory ? (
<TaggSquareButton
- onPress={moment ? handleDoneEditing : handleShare}
- title={'Post'}
+ onPress={moment ? handleSubmitEditChanges : handleShare}
+ title={moment ? 'Update' : 'Post'}
buttonStyle={'large'}
buttonColor={'blue'}
labelColor={'white'}
@@ -326,8 +327,8 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
) : (
<TaggSquareButton
disabled={true}
- onPress={moment ? handleDoneEditing : handleShare}
- title={'Post'}
+ onPress={moment ? handleSubmitEditChanges : handleShare}
+ title={moment ? 'Update' : 'Post'}
buttonStyle={'large'}
buttonColor={'blue'}
labelColor={'white'}
diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts
index 0c93876a..50cedef9 100644
--- a/src/services/MomentService.ts
+++ b/src/services/MomentService.ts
@@ -59,6 +59,7 @@ export const postMoment = async (
export const patchMoment = async (
momentId: string,
caption: string,
+ category: string,
tags: {
x: number;
y: number;
@@ -69,7 +70,8 @@ export const patchMoment = async (
try {
const request = new FormData();
request.append('moment_id', momentId);
- request.append('captions', JSON.stringify({[momentId]: caption}));
+ request.append('caption', caption);
+ request.append('category', category);
request.append('tags', JSON.stringify(tags));
const token = await AsyncStorage.getItem('token');
let response = await fetch(MOMENTS_ENDPOINT, {