fix(settings): guard empty-token copy, search platform filter and clear button

This commit is contained in:
Gauvain
2026-06-04 00:00:08 +02:00
parent ac5dcbe751
commit f56b2bc4eb
4 changed files with 10 additions and 2 deletions

View File

@@ -38,6 +38,7 @@ export default function AccountPage() {
title={t("home.settings.account.copy_token")} title={t("home.settings.account.copy_token")}
textColor='blue' textColor='blue'
onPress={async () => { onPress={async () => {
if (!token) return;
await setStringAsync(token); await setStringAsync(token);
success(); success();
Alert.alert(t("home.settings.account.copied")); Alert.alert(t("home.settings.account.copied"));

View File

@@ -1,7 +1,7 @@
import { Ionicons } from "@expo/vector-icons"; import { Ionicons } from "@expo/vector-icons";
import { t } from "i18next"; import { t } from "i18next";
import type React from "react"; import type React from "react";
import { TextInput, View } from "react-native"; import { TextInput, TouchableOpacity, View } from "react-native";
export const SettingsSearchBar: React.FC<{ export const SettingsSearchBar: React.FC<{
value: string; value: string;
@@ -17,7 +17,12 @@ export const SettingsSearchBar: React.FC<{
className='flex-1 ml-2 text-white text-[15px]' className='flex-1 ml-2 text-white text-[15px]'
autoCapitalize='none' autoCapitalize='none'
autoCorrect={false} autoCorrect={false}
clearButtonMode='while-editing' returnKeyType='search'
/> />
{value.length > 0 ? (
<TouchableOpacity onPress={() => onChange("")} hitSlop={8}>
<Ionicons name='close-circle' size={18} color='#76767c' />
</TouchableOpacity>
) : null}
</View> </View>
); );

View File

@@ -3,6 +3,7 @@ export interface SearchableOption {
parentRoute: string; parentRoute: string;
parentTitleKey: string; parentTitleKey: string;
keywords?: string[]; keywords?: string[];
platforms?: ("ios" | "android")[];
} }
/** /**

View File

@@ -35,6 +35,7 @@ export const useSettingsSearch = (query: string): SearchResult[] => {
} }
} }
for (const o of SETTINGS_SEARCH_INDEX) { for (const o of SETTINGS_SEARCH_INDEX) {
if (o.platforms && !o.platforms.includes(os)) continue;
if (matchesQuery({ title: t(o.titleKey), keywords: o.keywords }, query)) { if (matchesQuery({ title: t(o.titleKey), keywords: o.keywords }, query)) {
results.push({ results.push({
id: `${o.parentRoute}#${o.titleKey}`, id: `${o.parentRoute}#${o.titleKey}`,