mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import React, { useMemo } from "react";
|
|
import { View } from "react-native";
|
|
import { useMMKVString } from "react-native-mmkv";
|
|
import { ListGroup } from "./list/ListGroup";
|
|
import { ListItem } from "./list/ListItem";
|
|
|
|
interface Server {
|
|
address: string;
|
|
}
|
|
|
|
interface PreviousServersListProps {
|
|
onServerSelect: (server: Server) => void;
|
|
}
|
|
|
|
export const PreviousServersList: React.FC<PreviousServersListProps> = ({
|
|
onServerSelect,
|
|
}) => {
|
|
const [_previousServers, setPreviousServers] =
|
|
useMMKVString("previousServers");
|
|
|
|
const previousServers = useMemo(() => {
|
|
return JSON.parse(_previousServers || "[]") as Server[];
|
|
}, [_previousServers]);
|
|
|
|
if (!previousServers.length) return null;
|
|
|
|
return (
|
|
<View>
|
|
<ListGroup title="previous servers" className="mt-4">
|
|
{previousServers.map((s) => (
|
|
<ListItem
|
|
key={s.address}
|
|
onPress={() => onServerSelect(s)}
|
|
title={s.address}
|
|
showArrow
|
|
/>
|
|
))}
|
|
<ListItem
|
|
onPress={() => {
|
|
setPreviousServers("[]");
|
|
}}
|
|
title={"Clear"}
|
|
textColor="red"
|
|
/>
|
|
</ListGroup>
|
|
</View>
|
|
);
|
|
};
|