aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-07-23 14:48:37 -0400
committerIvan Chen <ivan@tagg.id>2021-07-23 14:48:37 -0400
commit9a043ad37aefb5c1b5908c4171cef36977acd5f4 (patch)
tree92600123f1fa6d93caa38ab9a79a79493014da2c /src
parent40fb142271a59b4a6f39f8995948e25dc21fe176 (diff)
Fix finish process check issue, Adjust progress bar timing
Diffstat (limited to 'src')
-rw-r--r--src/components/moments/MomentUploadProgressBar.tsx17
-rw-r--r--src/constants/api.ts2
-rw-r--r--src/services/MomentService.ts6
3 files changed, 11 insertions, 14 deletions
diff --git a/src/components/moments/MomentUploadProgressBar.tsx b/src/components/moments/MomentUploadProgressBar.tsx
index 0c93ea95..9412fcd6 100644
--- a/src/components/moments/MomentUploadProgressBar.tsx
+++ b/src/components/moments/MomentUploadProgressBar.tsx
@@ -8,7 +8,7 @@ import {
withTiming,
} from 'react-native-reanimated';
import {useDispatch, useSelector} from 'react-redux';
-import {checkMomentUploadFinished} from '../../services';
+import {checkMomentDoneProcessing} from '../../services';
import {loadUserMoments} from '../../store/actions';
import {setMomentUploadProgressBar} from '../../store/reducers';
import {RootState} from '../../store/rootReducer';
@@ -36,10 +36,10 @@ const MomentUploadProgressBar: React.FC<MomentUploadProgressBarProps> =
useEffect(() => {
let doneProcessing = false;
- const checkDone = () => {
+ const checkDone = async () => {
if (
momentUploadProgressBar &&
- checkMomentUploadFinished(momentUploadProgressBar?.momentId)
+ (await checkMomentDoneProcessing(momentUploadProgressBar!.momentId))
) {
doneProcessing = true;
cancelAnimation(progress);
@@ -51,6 +51,7 @@ const MomentUploadProgressBar: React.FC<MomentUploadProgressBarProps> =
});
// change status to Done 1s after the progress bar animation is done
setTimeout(() => {
+ dispatch(loadUserMoments(loggedInUserId));
dispatch({
type: setMomentUploadProgressBar.type,
payload: {
@@ -60,7 +61,7 @@ const MomentUploadProgressBar: React.FC<MomentUploadProgressBarProps> =
},
},
});
- }, finishProgressBarDuration + 1000);
+ }, finishProgressBarDuration);
}
};
if (
@@ -97,11 +98,10 @@ const MomentUploadProgressBar: React.FC<MomentUploadProgressBarProps> =
if (
momentUploadProgressBar?.status === MomentUploadStatusType.UploadingToS3
) {
- // assume it takes video duration (upload) + 1/2 of the video (process) duration to upload
- // e.g. 30s video => 30 + 30 * .5 = 37.5s
+ // e.g. 30s video => 30 * 2 = 60s
const videoDuration =
momentUploadProgressBar.originalVideoDuration ?? 30;
- const durationInSeconds = videoDuration * 1.5;
+ const durationInSeconds = videoDuration * 2;
progress.value = withTiming(1, {
duration: durationInSeconds * 1000,
easing: Easing.out(Easing.quad),
@@ -117,9 +117,6 @@ const MomentUploadProgressBar: React.FC<MomentUploadProgressBarProps> =
progress.value = 0;
// clear this component after a duration
setTimeout(() => {
- if (momentUploadProgressBar?.status === MomentUploadStatusType.Done) {
- dispatch(loadUserMoments(loggedInUserId));
- }
dispatch({
type: setMomentUploadProgressBar.type,
payload: {
diff --git a/src/constants/api.ts b/src/constants/api.ts
index ec2f0897..b4548634 100644
--- a/src/constants/api.ts
+++ b/src/constants/api.ts
@@ -39,7 +39,7 @@ export const COMMENTS_ENDPOINT: string = API_URL + 'comments/';
export const COMMENT_REACTIONS_ENDPOINT: string = API_URL + 'reaction-comment/';
export const COMMENT_REACTIONS_REPLY_ENDPOINT: string = API_URL + 'reaction-reply/';
export const PRESIGNED_URL_ENDPOINT: string = API_URL + 'presigned-url/';
-export const CHECK_MOMENT_UPLOAD_FINISHED_ENDPOINT: string = API_URL + 'moments/check_upload_finished/';
+export const CHECK_MOMENT_UPLOAD_DONE_PROCESSING_ENDPOINT: string = API_URL + 'moments/check_done_processing/';
export const FRIENDS_ENDPOINT: string = API_URL + 'friends/';
export const ALL_USERS_ENDPOINT: string = API_URL + 'users/';
export const REPORT_ISSUE_ENDPOINT: string = API_URL + 'report/';
diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts
index 2a0d9113..b67cd169 100644
--- a/src/services/MomentService.ts
+++ b/src/services/MomentService.ts
@@ -1,7 +1,7 @@
import AsyncStorage from '@react-native-community/async-storage';
import RNFetchBlob from 'rn-fetch-blob';
import {
- CHECK_MOMENT_UPLOAD_FINISHED_ENDPOINT,
+ CHECK_MOMENT_UPLOAD_DONE_PROCESSING_ENDPOINT,
MOMENTS_ENDPOINT,
MOMENTTAG_ENDPOINT,
MOMENT_TAGS_ENDPOINT,
@@ -322,11 +322,11 @@ export const handleVideoUpload = async (
return false;
};
-export const checkMomentUploadFinished = async (momentId: string) => {
+export const checkMomentDoneProcessing = async (momentId: string) => {
try {
const token = await AsyncStorage.getItem('token');
const response = await fetch(
- CHECK_MOMENT_UPLOAD_FINISHED_ENDPOINT + '?moment_id=' + momentId,
+ CHECK_MOMENT_UPLOAD_DONE_PROCESSING_ENDPOINT + '?moment_id=' + momentId,
{
method: 'GET',
headers: {