Merge pull request #349 from cmorg3/add_search_nodes
feat: Add search functionality for nodes in Messages and Nodes pages
This commit is contained in:
+15
-3
@@ -20,9 +20,12 @@ const MessagesPage = () => {
|
|||||||
const [activeChat, setActiveChat] = useState<number>(
|
const [activeChat, setActiveChat] = useState<number>(
|
||||||
Types.ChannelNumber.Primary,
|
Types.ChannelNumber.Primary,
|
||||||
);
|
);
|
||||||
const filteredNodes = Array.from(nodes.values()).filter(
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
||||||
(n) => n.num !== hardware.myNodeNum,
|
const filteredNodes = Array.from(nodes.values()).filter((node) => {
|
||||||
);
|
if (node.num === hardware.myNodeNum) return false;
|
||||||
|
const nodeName = node.user?.longName ?? `!${numberToHexUnpadded(node.num)}`;
|
||||||
|
return nodeName.toLowerCase().includes(searchTerm.toLowerCase());
|
||||||
|
});
|
||||||
const allChannels = Array.from(channels.values());
|
const allChannels = Array.from(channels.values());
|
||||||
const filteredChannels = allChannels.filter(
|
const filteredChannels = allChannels.filter(
|
||||||
(ch) => ch.role !== Protobuf.Channel.Channel_Role.DISABLED,
|
(ch) => ch.role !== Protobuf.Channel.Channel_Role.DISABLED,
|
||||||
@@ -56,6 +59,15 @@ const MessagesPage = () => {
|
|||||||
))}
|
))}
|
||||||
</SidebarSection>
|
</SidebarSection>
|
||||||
<SidebarSection label="Nodes">
|
<SidebarSection label="Nodes">
|
||||||
|
<div className="p-4">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search nodes..."
|
||||||
|
value={searchTerm}
|
||||||
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
|
className="w-full p-2 border border-gray-300 rounded bg-white text-black"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
{filteredNodes.map((node) => (
|
{filteredNodes.map((node) => (
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
|
|||||||
+16
-3
@@ -9,6 +9,7 @@ import { useDevice } from "@core/stores/deviceStore.ts";
|
|||||||
import { Protobuf } from "@meshtastic/js";
|
import { Protobuf } from "@meshtastic/js";
|
||||||
import { numberToHexUnpadded } from "@noble/curves/abstract/utils";
|
import { numberToHexUnpadded } from "@noble/curves/abstract/utils";
|
||||||
import { LockIcon, LockOpenIcon, TrashIcon } from "lucide-react";
|
import { LockIcon, LockOpenIcon, TrashIcon } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
import { Fragment, type JSX } from "react";
|
import { Fragment, type JSX } from "react";
|
||||||
import { base16 } from "rfc4648";
|
import { base16 } from "rfc4648";
|
||||||
|
|
||||||
@@ -20,15 +21,27 @@ export interface DeleteNoteDialogProps {
|
|||||||
const NodesPage = (): JSX.Element => {
|
const NodesPage = (): JSX.Element => {
|
||||||
const { nodes, hardware, setDialogOpen } = useDevice();
|
const { nodes, hardware, setDialogOpen } = useDevice();
|
||||||
const { setNodeNumToBeRemoved } = useAppStore();
|
const { setNodeNumToBeRemoved } = useAppStore();
|
||||||
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
||||||
|
|
||||||
const filteredNodes = Array.from(nodes.values()).filter(
|
const filteredNodes = Array.from(nodes.values()).filter((node) => {
|
||||||
(n) => n.num !== hardware.myNodeNum,
|
if (node.num === hardware.myNodeNum) return false;
|
||||||
);
|
const nodeName = node.user?.longName ?? `!${numberToHexUnpadded(node.num)}`;
|
||||||
|
return nodeName.toLowerCase().includes(searchTerm.toLowerCase());
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<div className="flex flex-col w-full">
|
<div className="flex flex-col w-full">
|
||||||
|
<div className="p-4">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search nodes..."
|
||||||
|
value={searchTerm}
|
||||||
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
|
className="w-full p-2 border border-gray-300 rounded bg-white text-black"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="overflow-y-auto h-full">
|
<div className="overflow-y-auto h-full">
|
||||||
<Table
|
<Table
|
||||||
headings={[
|
headings={[
|
||||||
|
|||||||
Reference in New Issue
Block a user