Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download of VC is started when clicking "Back home" rather than when entering verification code #112

Merged
merged 2 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions screens/Home/MyVids/AddVidModal.tsx
Original file line number Diff line number Diff line change
@@ -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<AddVidModalProps> = (props) => {
const controller = useAddVidModal(props);

return (
<React.Fragment>
<IdInputModal
Expand All @@ -29,11 +28,6 @@ export const AddVidModal: React.FC<AddVidModalProps> = (props) => {
hasProgress
onCancel={controller.DISMISS}
/>

<DownloadingVidModal
isVisible={controller.isRequestSuccessful}
onDismiss={controller.DISMISS}
/>
</React.Fragment>
);
};
2 changes: 0 additions & 2 deletions screens/Home/MyVids/AddVidModalController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import {
AddVidModalMachine,
selectIsAcceptingOtpInput,
selectIsRequestingCredential,
selectIsRequestSuccessful,
selectOtpError,
selectIsAcceptingIdInput,
} from './AddVidModalMachine';

export function useAddVidModal({ service }: AddVidModalProps) {
return {
isRequestingCredential: useSelector(service, selectIsRequestingCredential),
isRequestSuccessful: useSelector(service, selectIsRequestSuccessful),

otpError: useSelector(service, selectOtpError),

Expand Down
14 changes: 3 additions & 11 deletions screens/Home/MyVids/AddVidModalMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
DoneInvokeEvent,
ErrorPlatformEvent,
EventFrom,
send,
sendParent,
StateFrom,
} from 'xstate';
Expand Down Expand Up @@ -143,7 +144,7 @@ export const AddVidModalMachine = model.createMachine(
invoke: {
src: 'requestCredential',
onDone: {
target: 'requestSuccessful',
target: 'done',
actions: ['setRequestId'],
},
onError: [
Expand All @@ -164,11 +165,6 @@ export const AddVidModalMachine = model.createMachine(
},
},
},
requestSuccessful: {
on: {
DISMISS: 'done',
},
},
done: {
type: 'final',
data: (context) => VID_ITEM_STORE_KEY(context),
Expand Down Expand Up @@ -303,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');
}
}
9 changes: 8 additions & 1 deletion screens/Home/MyVidsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HomeScreenTabProps> = (props) => {
const controller = useMyVidsTab(props);

return (
<React.Fragment>
<Column fill style={{ display: props.isVisible ? 'flex' : 'none' }}>
Expand Down Expand Up @@ -75,6 +76,12 @@ export const MyVidsTab: React.FC<HomeScreenTabProps> = (props) => {
{controller.AddVidModalService && (
<AddVidModal service={controller.AddVidModalService} />
)}
{controller.isRequestSuccessful && (
<DownloadingVidModal
isVisible={controller.isRequestSuccessful}
onDismiss={controller.DISMISS}
/>
)}

<OnboardingOverlay
isVisible={controller.isOnboarding}
Expand Down
2 changes: 2 additions & 0 deletions screens/Home/MyVidsTabController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
MyVidsTabMachine,
selectAddVidModal,
selectIsOnboarding,
selectIsRequestSuccessful,
} from './MyVidsTabMachine';

export function useMyVidsTab(props: HomeScreenTabProps) {
Expand All @@ -31,6 +32,7 @@ export function useMyVidsTab(props: HomeScreenTabProps) {
vidLabel: useSelector(settingsService, selectVidLabel),

isRefreshingVids: useSelector(vidService, selectIsRefreshingMyVids),
isRequestSuccessful: useSelector(service, selectIsRequestSuccessful),
isOnboarding: useSelector(service, selectIsOnboarding),

DISMISS: () => service.send(MyVidsTabEvents.DISMISS()),
Expand Down
11 changes: 10 additions & 1 deletion screens/Home/MyVidsTabMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ export const MyVidsTabMachine = model.createMachine(
entry: ['storeVidItem'],
on: {
STORE_RESPONSE: {
target: '#idle',
target: 'addVidSuccessful',
actions: ['sendVidAdded'],
},
},
},
addVidSuccessful: {
on: {
DISMISS: '#idle',
},
}
},
},
},
Expand Down Expand Up @@ -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');
}