Skip to content
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
47 changes: 1 addition & 46 deletions app/src/screens/account/settings/ProofSettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ import { dinot } from '@selfxyz/mobile-sdk-alpha/constants/fonts';
import { useSettingStore } from '@/stores/settingStore';

const ProofSettingsScreen: React.FC = () => {
const {
skipDocumentSelector,
setSkipDocumentSelector,
skipDocumentSelectorIfSingle,
setSkipDocumentSelectorIfSingle,
} = useSettingStore();
const { skipDocumentSelector, setSkipDocumentSelector } = useSettingStore();

return (
<YStack flex={1} backgroundColor={white}>
Expand All @@ -49,35 +44,6 @@ const ProofSettingsScreen: React.FC = () => {
testID="skip-document-selector-toggle"
/>
</View>

<View style={styles.divider} />

<View style={styles.settingRow}>
<View style={styles.settingTextContainer}>
<Text style={styles.settingLabel}>
Skip when only one document
</Text>
<Text style={styles.settingDescription}>
Automatically select your document when you only have one valid
ID available
</Text>
</View>
<Switch
value={skipDocumentSelectorIfSingle}
onValueChange={setSkipDocumentSelectorIfSingle}
trackColor={{ false: slate200, true: blue600 }}
thumbColor={white}
disabled={skipDocumentSelector}
testID="skip-document-selector-if-single-toggle"
/>
</View>

{skipDocumentSelector && (
<Text style={styles.infoText}>
Document selection is always skipped. The &quot;Skip when only one
document&quot; setting has no effect.
</Text>
)}
</YStack>
</ScrollView>
</YStack>
Expand Down Expand Up @@ -114,17 +80,6 @@ const styles = StyleSheet.create({
fontFamily: dinot,
color: slate500,
},
divider: {
height: 1,
backgroundColor: slate200,
},
infoText: {
fontSize: 13,
fontFamily: dinot,
fontStyle: 'italic',
color: slate500,
paddingHorizontal: 4,
},
});

export { ProofSettingsScreen };
12 changes: 3 additions & 9 deletions app/src/screens/verification/ProvingScreenRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { getDocumentTypeName } from '@/utils/documentUtils';
*
* This screen:
* 1. Loads document catalog and counts valid documents
* 2. Checks skip settings (skipDocumentSelector, skipDocumentSelectorIfSingle)
* 2. Checks skip settings (skipDocumentSelector, auto-skip on single document)
* 3. Routes to appropriate screen:
* - No valid documents -> DocumentDataNotFound
* - Skip enabled -> auto-select and go to Prove
Expand All @@ -37,8 +37,7 @@ const ProvingScreenRouter: React.FC = () => {
useNavigation<NativeStackNavigationProp<RootStackParamList>>();
const { loadDocumentCatalog, getAllDocuments, setSelectedDocument } =
usePassport();
const { skipDocumentSelector, skipDocumentSelectorIfSingle } =
useSettingStore();
const { skipDocumentSelector } = useSettingStore();
const [error, setError] = useState<string | null>(null);
const abortControllerRef = useRef<AbortController | null>(null);
const hasRoutedRef = useRef(false);
Expand Down Expand Up @@ -87,11 +86,7 @@ const ProvingScreenRouter: React.FC = () => {
const documentType = getDocumentTypeName(firstValidDoc?.documentCategory);

// Determine if we should skip the selector
const shouldSkip =
skipDocumentSelector ||
(skipDocumentSelectorIfSingle &&
validCount === 1 &&
firstValidDoc.isRegistered);
const shouldSkip = skipDocumentSelector || validCount === 1;

if (shouldSkip) {
// Auto-select and navigate to Prove
Expand Down Expand Up @@ -136,7 +131,6 @@ const ProvingScreenRouter: React.FC = () => {
navigation,
setSelectedDocument,
skipDocumentSelector,
skipDocumentSelectorIfSingle,
]);

useFocusEffect(
Expand Down
5 changes: 0 additions & 5 deletions app/src/stores/settingStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ interface PersistedSettingsState {
setLoggingSeverity: (severity: LoggingSeverity) => void;
setPointsAddress: (address: string | null) => void;
setSkipDocumentSelector: (value: boolean) => void;
setSkipDocumentSelectorIfSingle: (value: boolean) => void;
setSubscribedTopics: (topics: string[]) => void;
setTurnkeyBackupEnabled: (turnkeyBackupEnabled: boolean) => void;
setUseStrongBox: (useStrongBox: boolean) => void;
skipDocumentSelector: boolean;
skipDocumentSelectorIfSingle: boolean;
subscribedTopics: string[];
toggleCloudBackupEnabled: () => void;
turnkeyBackupEnabled: boolean;
Expand Down Expand Up @@ -145,9 +143,6 @@ export const useSettingStore = create<SettingsState>()(
skipDocumentSelector: false,
setSkipDocumentSelector: (value: boolean) =>
set({ skipDocumentSelector: value }),
skipDocumentSelectorIfSingle: true,
setSkipDocumentSelectorIfSingle: (value: boolean) =>
set({ skipDocumentSelectorIfSingle: value }),

// StrongBox setting for Android keystore (default: false)
useStrongBox: false,
Expand Down
14 changes: 11 additions & 3 deletions app/tests/src/screens/verification/ProvingScreenRouter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,23 @@ describe('ProvingScreenRouter', () => {
});

it('routes to the document selector when skipping is disabled', async () => {
const passport = createMetadata({
const passport1 = createMetadata({
id: 'doc-1',
documentType: 'us',
isRegistered: true,
});
const passport2 = createMetadata({
id: 'doc-2',
documentType: 'gb',
isRegistered: true,
});
const catalog: DocumentCatalog = {
documents: [passport],
documents: [passport1, passport2],
};
const allDocs = createAllDocuments([createDocumentEntry(passport)]);
const allDocs = createAllDocuments([
createDocumentEntry(passport1),
createDocumentEntry(passport2),
]);

mockLoadDocumentCatalog.mockResolvedValue(catalog);
mockGetAllDocuments.mockResolvedValue(allDocs);
Expand Down
Loading