import { Channel } from "@app/components/PageComponents/Channels/Channel"; import { Button } from "@components/UI/Button.tsx"; import { Spinner } from "@components/UI/Spinner.tsx"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@components/UI/Tabs.tsx"; import { useDevice } from "@core/stores"; import type { Protobuf } from "@meshtastic/core"; import i18next from "i18next"; import { QrCodeIcon, UploadIcon } from "lucide-react"; import { Suspense, useMemo } from "react"; import type { UseFormReturn } from "react-hook-form"; import { useTranslation } from "react-i18next"; interface ConfigProps { onFormInit: (methods: UseFormReturn) => void; } export const getChannelName = (channel: Protobuf.Channel.Channel) => { return channel.settings?.name.length ? channel.settings?.name : channel.index === 0 ? i18next.t("page.broadcastLabel") : i18next.t("page.channelIndex", { ns: "channels", index: channel.index, }); }; export const Channels = ({ onFormInit }: ConfigProps) => { const { channels, hasChannelChange, setDialogOpen } = useDevice(); const { t } = useTranslation("channels"); const allChannels = Array.from(channels.values()); const flags = useMemo( () => new Map(allChannels.map((channel) => [channel.index, hasChannelChange(channel.index)])), [allChannels, hasChannelChange], ); return ( {allChannels.map((channel) => ( {getChannelName(channel)} {flags.get(channel.index) && ( )} ))} {allChannels.map((channel) => ( }> ))} ); };