From 238677d3de8284a06b084ea18bfeeba2030053c4 Mon Sep 17 00:00:00 2001 From: Danica Erediano Date: Fri, 18 Mar 2022 13:22:00 +0800 Subject: [PATCH 1/2] moved DownloadingVidModal --- screens/Home/MyVids/AddVidModal.tsx | 8 +------- screens/Home/MyVids/AddVidModalMachine.ts | 2 ++ screens/Home/MyVidsTab.tsx | 9 ++++++++- screens/Home/MyVidsTabController.ts | 2 ++ screens/Home/MyVidsTabMachine.ts | 11 ++++++++++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/screens/Home/MyVids/AddVidModal.tsx b/screens/Home/MyVids/AddVidModal.tsx index 7734891010..5bc75ddd77 100644 --- a/screens/Home/MyVids/AddVidModal.tsx +++ b/screens/Home/MyVids/AddVidModal.tsx @@ -1,13 +1,12 @@ import React from 'react'; import { MessageOverlay } from '../../../components/MessageOverlay'; import { AddVidModalProps, useAddVidModal } from './AddVidModalController'; -import { DownloadingVidModal } from './DownloadingVidModal'; import { OtpVerificationModal } from './OtpVerificationModal'; import { IdInputModal } from './IdInputModal'; export const AddVidModal: React.FC = (props) => { const controller = useAddVidModal(props); - + return ( = (props) => { hasProgress onCancel={controller.DISMISS} /> - - ); }; diff --git a/screens/Home/MyVids/AddVidModalMachine.ts b/screens/Home/MyVids/AddVidModalMachine.ts index 5cb6c89de6..0347caa379 100644 --- a/screens/Home/MyVids/AddVidModalMachine.ts +++ b/screens/Home/MyVids/AddVidModalMachine.ts @@ -3,6 +3,7 @@ import { DoneInvokeEvent, ErrorPlatformEvent, EventFrom, + send, sendParent, StateFrom, } from 'xstate'; @@ -165,6 +166,7 @@ export const AddVidModalMachine = model.createMachine( }, }, requestSuccessful: { + entry: [send('DISMISS')], on: { DISMISS: 'done', }, diff --git a/screens/Home/MyVidsTab.tsx b/screens/Home/MyVidsTab.tsx index 713dc0c222..72cd25fe36 100644 --- a/screens/Home/MyVidsTab.tsx +++ b/screens/Home/MyVidsTab.tsx @@ -7,12 +7,13 @@ import { RefreshControl } from 'react-native'; import { useMyVidsTab } from './MyVidsTabController'; import { HomeScreenTabProps } from './HomeScreen'; import { AddVidModal } from './MyVids/AddVidModal'; +import { DownloadingVidModal } from './MyVids/DownloadingVidModal'; import { OnboardingOverlay } from './OnboardingOverlay'; import { MessageOverlay } from '../../components/MessageOverlay'; export const MyVidsTab: React.FC = (props) => { const controller = useMyVidsTab(props); - + return ( @@ -75,6 +76,12 @@ export const MyVidsTab: React.FC = (props) => { {controller.AddVidModalService && ( )} + {controller.isRequestSuccessful && ( + + )} service.send(MyVidsTabEvents.DISMISS()), diff --git a/screens/Home/MyVidsTabMachine.ts b/screens/Home/MyVidsTabMachine.ts index 34ef72424c..a296dcb82e 100644 --- a/screens/Home/MyVidsTabMachine.ts +++ b/screens/Home/MyVidsTabMachine.ts @@ -101,11 +101,16 @@ export const MyVidsTabMachine = model.createMachine( entry: ['storeVidItem'], on: { STORE_RESPONSE: { - target: '#idle', + target: 'addVidSuccessful', actions: ['sendVidAdded'], }, }, }, + addVidSuccessful: { + on: { + DISMISS: '#idle', + }, + } }, }, }, @@ -160,3 +165,7 @@ export function selectAddVidModal(state: State) { export function selectIsOnboarding(state: State) { return state.matches('onboarding'); } + +export function selectIsRequestSuccessful(state: State) { + return state.matches('addingVid.addVidSuccessful'); +} From fd8665998bad85a17d0c63af834f82dd1bd4d396 Mon Sep 17 00:00:00 2001 From: Danica Erediano Date: Fri, 18 Mar 2022 15:36:43 +0800 Subject: [PATCH 2/2] removed requestSuccessful state --- screens/Home/MyVids/AddVidModalController.ts | 2 -- screens/Home/MyVids/AddVidModalMachine.ts | 14 ++------------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/screens/Home/MyVids/AddVidModalController.ts b/screens/Home/MyVids/AddVidModalController.ts index 490724cbee..464a884e5c 100644 --- a/screens/Home/MyVids/AddVidModalController.ts +++ b/screens/Home/MyVids/AddVidModalController.ts @@ -5,7 +5,6 @@ import { AddVidModalMachine, selectIsAcceptingOtpInput, selectIsRequestingCredential, - selectIsRequestSuccessful, selectOtpError, selectIsAcceptingIdInput, } from './AddVidModalMachine'; @@ -13,7 +12,6 @@ import { export function useAddVidModal({ service }: AddVidModalProps) { return { isRequestingCredential: useSelector(service, selectIsRequestingCredential), - isRequestSuccessful: useSelector(service, selectIsRequestSuccessful), otpError: useSelector(service, selectOtpError), diff --git a/screens/Home/MyVids/AddVidModalMachine.ts b/screens/Home/MyVids/AddVidModalMachine.ts index 0347caa379..16f8751297 100644 --- a/screens/Home/MyVids/AddVidModalMachine.ts +++ b/screens/Home/MyVids/AddVidModalMachine.ts @@ -144,7 +144,7 @@ export const AddVidModalMachine = model.createMachine( invoke: { src: 'requestCredential', onDone: { - target: 'requestSuccessful', + target: 'done', actions: ['setRequestId'], }, onError: [ @@ -165,12 +165,6 @@ export const AddVidModalMachine = model.createMachine( }, }, }, - requestSuccessful: { - entry: [send('DISMISS')], - on: { - DISMISS: 'done', - }, - }, done: { type: 'final', data: (context) => VID_ITEM_STORE_KEY(context), @@ -305,8 +299,4 @@ export function selectIsRequestingOtp(state: State) { export function selectIsRequestingCredential(state: State) { return state.matches('requestingCredential'); -} - -export function selectIsRequestSuccessful(state: State) { - return state.matches('requestSuccessful'); -} +} \ No newline at end of file