Skip to content

Commit

Permalink
Discard commits to sync fork.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmigueld committed Jan 29, 2024
1 parent bb418e7 commit b5de93b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 7 deletions.
2 changes: 2 additions & 0 deletions components/DeviceInfoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ interface DeviceInfoProps {

export interface DeviceInfo {
deviceName: string;
name: string;
deviceId: string;
}
3 changes: 2 additions & 1 deletion machines/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,8 @@ export const requestMachine =
_vcKey: VC_ITEM_STORE_KEY(context.incomingVc),
type: context.receiveLogType,
timestamp: Date.now(),
deviceName: context.senderInfo.deviceName,
deviceName:
context.senderInfo.name || context.senderInfo.deviceName,
vcLabel: context.incomingVc.tag || context.incomingVc.id,
}),
{ to: (context) => context.serviceRefs.activityLog }
Expand Down
8 changes: 4 additions & 4 deletions machines/revoke.typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export interface Typegen0 {
};
'missingImplementations': {
actions: never;
delays: never;
guards: never;
services: never;
guards: never;
delays: never;
};
'eventsCausingActions': {
clearOtp:
Expand All @@ -39,12 +39,12 @@ export interface Typegen0 {
setTransactionId: 'DISMISS' | 'REVOKE_VCS' | 'xstate.init';
setVIDs: 'REVOKE_VCS';
};
'eventsCausingDelays': {};
'eventsCausingGuards': {};
'eventsCausingServices': {
requestOtp: never;
requestRevoke: 'INPUT_OTP';
};
'eventsCausingGuards': {};
'eventsCausingDelays': {};
'matchesStates':
| 'acceptingOtpInput'
| 'acceptingVIDs'
Expand Down
6 changes: 4 additions & 2 deletions machines/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ export const scanMachine =
? 'VC_SHARED_WITH_VERIFICATION_CONSENT'
: context.shareLogType,
timestamp: Date.now(),
deviceName: context.receiverInfo.deviceName,
deviceName:
context.receiverInfo.name || context.receiverInfo.deviceName,
vcLabel: context.selectedVc.tag || context.selectedVc.id,
}),
{ to: (context) => context.serviceRefs.activityLog }
Expand All @@ -603,7 +604,8 @@ export const scanMachine =
_vcKey: VC_ITEM_STORE_KEY(context.selectedVc),
type: 'PRESENCE_VERIFICATION_FAILED',
timestamp: Date.now(),
deviceName: context.receiverInfo.deviceName,
deviceName:
context.receiverInfo.name || context.receiverInfo.deviceName,
vcLabel: context.selectedVc.tag || context.selectedVc.id,
}),
{ to: (context) => context.serviceRefs.activityLog }
Expand Down
13 changes: 13 additions & 0 deletions machines/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { StoreEvents } from './store';
const model = createModel(
{
serviceRefs: {} as AppServices,
name: '',
vcLabel: {
singular: 'ID',
plural: 'IDs',
Expand All @@ -16,6 +17,7 @@ const model = createModel(
},
{
events: {
UPDATE_NAME: (name: string) => ({ name }),
UPDATE_VC_LABEL: (label: string) => ({ label }),
TOGGLE_BIOMETRIC_UNLOCK: (enable: boolean) => ({ enable }),
STORE_RESPONSE: (response: unknown) => ({ response }),
Expand Down Expand Up @@ -58,6 +60,9 @@ export const settingsMachine = model.createMachine(
TOGGLE_BIOMETRIC_UNLOCK: {
actions: ['toggleBiometricUnlock', 'storeContext'],
},
UPDATE_NAME: {
actions: ['updateName', 'storeContext'],
},
UPDATE_VC_LABEL: {
actions: ['updateVcLabel', 'storeContext'],
},
Expand Down Expand Up @@ -87,6 +92,10 @@ export const settingsMachine = model.createMachine(
};
}),

updateName: model.assign({
name: (_, event) => event.name,
}),

updateVcLabel: model.assign({
vcLabel: (_, event) => ({
singular: event.label,
Expand Down Expand Up @@ -116,6 +125,10 @@ export function createSettingsMachine(serviceRefs: AppServices) {

type State = StateFrom<typeof settingsMachine>;

export function selectName(state: State) {
return state.context.name;
}

export function selectVcLabel(state: State) {
return state.context.vcLabel;
}
Expand Down
2 changes: 2 additions & 0 deletions machines/settings.typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export interface Typegen0 {
storeContext:
| 'STORE_RESPONSE'
| 'TOGGLE_BIOMETRIC_UNLOCK'
| 'UPDATE_NAME'
| 'UPDATE_VC_LABEL';
toggleBiometricUnlock: 'TOGGLE_BIOMETRIC_UNLOCK';
updateName: 'UPDATE_NAME';
updateVcLabel: 'UPDATE_VC_LABEL';
};
'eventsCausingDelays': {};
Expand Down
5 changes: 5 additions & 0 deletions screens/Profile/ProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export const ProfileScreen: React.FC<MainRouteProps> = (props) => {
onBackdropPress={controller.hideAlert}
title={controller.alertMsg}
/>
<EditableListItem
label={t('name')}
value={controller.name}
onEdit={controller.UPDATE_NAME}
/>
<EditableListItem
label={t('vcLabel')}
value={controller.vcLabel.singular}
Expand Down
5 changes: 5 additions & 0 deletions screens/Profile/ProfileScreenController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '../../machines/auth';
import {
selectBiometricUnlockEnabled,
selectName,
selectVcLabel,
SettingsEvents,
} from '../../machines/settings';
Expand Down Expand Up @@ -93,6 +94,7 @@ export function useProfileScreen({ navigation }: MainRouteProps) {
alertMsg,
hideAlert,
backendInfo: useSelector(appService, selectBackendInfo),
name: useSelector(settingsService, selectName),
vcLabel: useSelector(settingsService, selectVcLabel),
isBiometricUnlockEnabled: useSelector(
settingsService,
Expand All @@ -101,6 +103,9 @@ export function useProfileScreen({ navigation }: MainRouteProps) {
canUseBiometrics: useSelector(authService, selectCanUseBiometrics),
useBiometrics,

UPDATE_NAME: (name: string) =>
settingsService.send(SettingsEvents.UPDATE_NAME(name)),

UPDATE_VC_LABEL: (label: string) =>
settingsService.send(SettingsEvents.UPDATE_VC_LABEL(label)),

Expand Down

0 comments on commit b5de93b

Please sign in to comment.