mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-04 13:08:33 +01:00
fix(settings): address CodeRabbit review (guard clipboard copy, reuse getUserImageUrl, hoist search title)
This commit is contained in:
@@ -1,21 +1,26 @@
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { Image } from "expo-image";
|
||||
import { LinearGradient } from "expo-linear-gradient";
|
||||
import { useAtom } from "jotai";
|
||||
import { useAtomValue } from "jotai";
|
||||
import type React from "react";
|
||||
import { TouchableOpacity, View } from "react-native";
|
||||
import { Text } from "@/components/common/Text";
|
||||
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
|
||||
import { getUserImageUrl } from "@/utils/jellyfin/image/getUserImageUrl";
|
||||
|
||||
export const SettingsHero: React.FC<{ onPress: () => void }> = ({
|
||||
onPress,
|
||||
}) => {
|
||||
const [api] = useAtom(apiAtom);
|
||||
const [user] = useAtom(userAtom);
|
||||
const api = useAtomValue(apiAtom);
|
||||
const user = useAtomValue(userAtom);
|
||||
const connected = Boolean(api && user);
|
||||
const imageUrl =
|
||||
api && user?.Id && user.PrimaryImageTag
|
||||
? `${api.basePath}/Users/${user.Id}/Images/Primary?tag=${user.PrimaryImageTag}&quality=90`
|
||||
api && user?.Id
|
||||
? (getUserImageUrl({
|
||||
serverAddress: api.basePath,
|
||||
userId: user.Id,
|
||||
primaryImageTag: user.PrimaryImageTag,
|
||||
}) ?? undefined)
|
||||
: undefined;
|
||||
const host = api?.basePath?.replace(/^https?:\/\//, "");
|
||||
|
||||
|
||||
@@ -22,24 +22,19 @@ export const useSettingsSearch = (query: string): SearchResult[] => {
|
||||
for (const section of SETTINGS_CATALOG) {
|
||||
for (const e of section.entries) {
|
||||
if (e.platforms && !e.platforms.includes(os)) continue;
|
||||
if (
|
||||
matchesQuery({ title: t(e.titleKey), keywords: e.keywords }, query)
|
||||
) {
|
||||
results.push({
|
||||
id: e.id,
|
||||
title: t(e.titleKey),
|
||||
icon: e.icon,
|
||||
target: e.target,
|
||||
});
|
||||
const title = t(e.titleKey);
|
||||
if (matchesQuery({ title, keywords: e.keywords }, query)) {
|
||||
results.push({ id: e.id, title, icon: e.icon, target: e.target });
|
||||
}
|
||||
}
|
||||
}
|
||||
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)) {
|
||||
const title = t(o.titleKey);
|
||||
if (matchesQuery({ title, keywords: o.keywords }, query)) {
|
||||
results.push({
|
||||
id: `${o.parentRoute}#${o.titleKey}`,
|
||||
title: t(o.titleKey),
|
||||
title,
|
||||
icon: "search",
|
||||
subtitle: t(o.parentTitleKey),
|
||||
target: { type: "route", route: o.parentRoute },
|
||||
|
||||
Reference in New Issue
Block a user