forked from mosip/inji-wallet
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#84): [Pooja|Tilak] remove old nearby state machines and refact…
…or selectors
- Loading branch information
1 parent
e5a3b69
commit da125f0
Showing
17 changed files
with
321 additions
and
2,510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { StateFrom } from 'xstate'; | ||
import { scanMachine } from './scan/machine'; | ||
import { requestMachine } from './request/machine'; | ||
|
||
type State = StateFrom<typeof scanMachine & typeof requestMachine>; | ||
|
||
export function selectIsCancelling(state: State) { | ||
return state.matches('cancelling'); | ||
} | ||
|
||
export function selectIsReviewing(state: State) { | ||
return state.matches('reviewing'); | ||
} | ||
|
||
export function selectIsAccepted(state: State) { | ||
return state.matches('reviewing.accepted'); | ||
} | ||
|
||
export function selectIsRejected(state: State) { | ||
return state.matches('reviewing.rejected'); | ||
} | ||
|
||
export function selectIsVerifyingIdentity(state: State) { | ||
return state.matches('reviewing.verifyingIdentity'); | ||
} | ||
|
||
export function selectIsInvalidIdentity(state: State) { | ||
return state.matches('reviewing.invalidIdentity'); | ||
} | ||
|
||
export function selectIsDisconnected(state: State) { | ||
return state.matches('disconnected'); | ||
} | ||
|
||
export function selectIsBluetoothDenied(state: State) { | ||
return state.matches('bluetoothDenied'); | ||
} | ||
|
||
// TODO: Remove these selectors and respective UI code once discussed with team | ||
export function selectIsExchangingDeviceInfo() { | ||
return false; | ||
} | ||
|
||
export function selectIsExchangingDeviceInfoTimeout() { | ||
return false; | ||
} | ||
|
||
export function selectIsDone(state: State) { | ||
return state.matches('reviewing.navigatingToHome'); | ||
} | ||
|
||
export function selectIsOffline() { | ||
return false; | ||
} | ||
|
||
export function selectIsHandlingBleError(state: State) { | ||
return state.matches('handlingBleError'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { StateFrom } from 'xstate'; | ||
import { requestMachine } from './machine'; | ||
|
||
type State = StateFrom<typeof requestMachine>; | ||
|
||
export function selectSenderInfo(state: State) { | ||
return state.context.senderInfo; | ||
} | ||
|
||
export function selectIncomingVc(state: State) { | ||
return state.context.incomingVc; | ||
} | ||
|
||
export function selectSharingProtocol(state: State) { | ||
return state.context.sharingProtocol; | ||
} | ||
|
||
export function selectIsIncomingVp(state: State) { | ||
return state.context.incomingVc?.verifiablePresentation != null; | ||
} | ||
|
||
export function selectIsReviewingInIdle(state: State) { | ||
return state.matches('reviewing.idle'); | ||
} | ||
|
||
export function selectIsWaitingForConnection(state: State) { | ||
return state.matches('waitingForConnection'); | ||
} | ||
|
||
export function selectIsCheckingBluetoothService(state: State) { | ||
return state.matches('checkingBluetoothService'); | ||
} | ||
|
||
export function selectIsWaitingForVc(state: State) { | ||
return state.matches('waitingForVc.inProgress'); | ||
} | ||
|
||
export function selectIsWaitingForVcTimeout(state: State) { | ||
return state.matches('waitingForVc.timeout'); | ||
} | ||
|
||
export function selectOpenId4VpUri(state: State) { | ||
return state.context.openId4VpUri; | ||
} | ||
|
||
export function selectIsAccepting(state: State) { | ||
return state.matches('reviewing.accepting'); | ||
} | ||
|
||
export function selectIsSavingFailedInIdle(state: State) { | ||
return state.matches('reviewing.savingFailed.idle'); | ||
} | ||
|
||
export function selectIsSavingFailedInViewingVc(state: State) { | ||
return state.matches('reviewing.savingFailed.viewingVc'); | ||
} | ||
|
||
export function selectStoreError(state: State) { | ||
return state.context.storeError; | ||
} |
Oops, something went wrong.