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

fix(INJI-329): fix received card expand view and redirect the user to history screen after VC transfer #799

Merged
merged 6 commits into from
Sep 12, 2023
2 changes: 1 addition & 1 deletion routes/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export type MainBottomTabParamList = {
activeTab: number;
};
Scan: undefined;
History: undefined;
history: undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can we have consistent naming for routes? Scan is starting with capital letter while others are not
  2. Can we reuse this value in initialised of tab screen at line number 36 also? to avoid mismatch for all routes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, extracted the bottom tab, scan and request screen names into separate file to maintain the consistency

};

export interface TabScreen {
Expand Down
4 changes: 0 additions & 4 deletions screens/Home/MyVcsTabController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
MyVcsTabEvents,
MyVcsTabMachine,
selectAddVcModal,
selectIsOnboarding,
selectIsRequestSuccessful,
selectGetVcModal,
selectIsSavingFailedInIdle,
Expand Down Expand Up @@ -46,7 +45,6 @@ export function useMyVcsTab(props: HomeScreenTabProps) {

isRefreshingVcs: useSelector(vcService, selectIsRefreshingMyVcs),
isRequestSuccessful: useSelector(service, selectIsRequestSuccessful),
isOnboarding: useSelector(service, selectIsOnboarding),
isSavingFailedInIdle: useSelector(service, selectIsSavingFailedInIdle),
walletBindingError: useSelector(service, selectWalletBindingError),
isBindingError: useSelector(service, selectShowWalletBindingError),
Expand All @@ -70,8 +68,6 @@ export function useMyVcsTab(props: HomeScreenTabProps) {
return service.send(MyVcsTabEvents.VIEW_VC(vcRef));
},

ONBOARDING_DONE: () => service.send(MyVcsTabEvents.ONBOARDING_DONE()),

IS_TAMPERED: () => service.send(MyVcsTabEvents.IS_TAMPERED()),

ACCEPT_HARDWARE_SUPPORT_NOT_EXISTS: () =>
Expand Down
49 changes: 2 additions & 47 deletions screens/Home/MyVcsTabMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import { StoreEvents, StoreResponseEvent } from '../../machines/store';
import { VcEvents } from '../../machines/vc';
import { vcItemMachine } from '../../machines/vcItem';
import { AppServices } from '../../shared/GlobalContext';
import {
MY_VCS_STORE_KEY,
ONBOARDING_STATUS_STORE_KEY,
} from '../../shared/constants';
import { MY_VCS_STORE_KEY } from '../../shared/constants';
import { AddVcModalMachine } from './MyVcs/AddVcModalMachine';
import { GetVcModalMachine } from './MyVcs/GetVcModalMachine';
import Storage from '../../shared/storage';
Expand All @@ -36,7 +33,6 @@ const model = createModel(
GET_VC: () => ({}),
STORAGE_AVAILABLE: () => ({}),
STORAGE_UNAVAILABLE: () => ({}),
ONBOARDING_DONE: () => ({}),
IS_TAMPERED: () => ({}),
},
}
Expand All @@ -57,31 +53,8 @@ export const MyVcsTabMachine = model.createMachine(
events: {} as EventFrom<typeof model>,
},
id: 'MyVcsTab',
initial: 'checkingOnboardingStatus',
initial: 'idle',
states: {
checkingOnboardingStatus: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the onboarding flow removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the old code we were using Onboarding status variable to decide whether we need to show the intro sliders in the MyVCs screen or not and when the app is installed and download the first VC we are setting that variable to true considering that onboarding is completed but there is a issue with this approach -
on the verifier side if we click on the received card we are creating new instance of MyVCS machine and it checks whether onboarding is completed or not since we didn't download the new vc that variable is not set to true and it will go into "Onboarding" state and inside this state there is no "VIEW_VC" event and the received card detailed view is failing because of this.
Now we are checking whether onboarding is done or not by checking if language preference is done or not so onboarding flow is not required

entry: ['getOnboardingStatus'],
on: {
STORE_RESPONSE: [
{ cond: 'isOnboardingDone', target: 'idle' },
{ target: 'onboarding' },
],
},
},
onboarding: {
on: {
ADD_VC: [
{
target: 'addVc',
actions: ['completeOnboarding'],
},
],
ONBOARDING_DONE: {
target: 'idle',
actions: ['completeOnboarding'],
},
},
},
addVc: {
initial: 'checkStorage',
states: {
Expand Down Expand Up @@ -202,16 +175,6 @@ export const MyVcsTabMachine = model.createMachine(
model.events.VIEW_VC(event.vcItemActor)
),

getOnboardingStatus: send(
() => StoreEvents.GET(ONBOARDING_STATUS_STORE_KEY),
{ to: (context) => context.serviceRefs.store }
),

completeOnboarding: send(
() => StoreEvents.SET(ONBOARDING_STATUS_STORE_KEY, true),
{ to: (context) => context.serviceRefs.store }
),

storeVcItem: send(
(_context, event) => {
return StoreEvents.PREPEND(
Expand All @@ -231,10 +194,6 @@ export const MyVcsTabMachine = model.createMachine(
},

guards: {
isOnboardingDone: (_context, event: StoreResponseEvent) => {
return event.response === true;
},

isMinimumStorageLimitReached: (_context, event) => Boolean(event.data),
},
}
Expand All @@ -257,10 +216,6 @@ export function selectGetVcModal(state: State) {
return state.children.GetVcModal as ActorRefFrom<typeof GetVcModalMachine>;
}

export function selectIsOnboarding(state: State) {
return state.matches('onboarding');
}

export function selectIsRequestSuccessful(state: State) {
return state.matches('addingVc.addVcSuccessful');
}
Expand Down
5 changes: 0 additions & 5 deletions screens/Home/MyVcsTabMachine.typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export interface Typegen0 {
services: never;
};
'eventsCausingActions': {
completeOnboarding: 'ADD_VC' | 'ONBOARDING_DONE';
getOnboardingStatus: 'xstate.init';
refreshMyVc: 'IS_TAMPERED';
resetIsTampered: 'IS_TAMPERED';
sendVcAdded: 'STORE_RESPONSE';
Expand All @@ -41,7 +39,6 @@ export interface Typegen0 {
'eventsCausingDelays': {};
'eventsCausingGuards': {
isMinimumStorageLimitReached: 'done.invoke.MyVcsTab.addVc.checkStorage:invocation[0]';
isOnboardingDone: 'STORE_RESPONSE';
};
'eventsCausingServices': {
AddVcModal:
Expand All @@ -60,11 +57,9 @@ export interface Typegen0 {
| 'addingVc.savingFailed.idle'
| 'addingVc.storing'
| 'addingVc.waitingForvcKey'
| 'checkingOnboardingStatus'
| 'gettingVc'
| 'gettingVc.waitingForvcKey'
| 'idle'
| 'onboarding'
| 'viewingVc'
| {
addVc?: 'checkStorage' | 'storageLimitReached';
Expand Down
2 changes: 1 addition & 1 deletion screens/Request/RequestLayoutController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function useRequestLayout() {
);
useEffect(() => {
if (isDone) {
navigation.navigate('History');
navigation.navigate('history');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for users, Immediately navigating to history screen might be unexpected as he would want to see the VC that he has received before moving to different screen

Copy link
Contributor Author

@PuBHARGAVI PuBHARGAVI Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed with @Kratitva regarding this, After closing the success popup we will be in the incoming card screen and only if the user clicks on View received card the user will be redirected to Received cards screen and if the user click on back button they will be redirected to QR code screen. I will make changes in the code

} else if (isReviewing) {
navigation.navigate('ReceiveVcScreen');
} else if (isWaitingForConnection) {
Expand Down
2 changes: 0 additions & 2 deletions shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export const ACTIVITY_LOG_STORE_KEY = 'activityLog';

export const SETTINGS_STORE_KEY = 'settings';

export const ONBOARDING_STATUS_STORE_KEY = 'isOnboardingDone';

export const GNM_API_KEY = GOOGLE_NEARBY_MESSAGES_API_KEY;

// https://developers.google.com/android/reference/com/google/android/gms/nearby/messages/Message#MAX_CONTENT_SIZE_BYTES
Expand Down