mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-03 03:53:10 +02:00
Make repeaters blockable, and hide from the sidebar
This commit is contained in:
@@ -471,6 +471,8 @@ export function App() {
|
||||
favorites,
|
||||
legacySortOrder: appSettings?.sidebar_sort_order,
|
||||
isConversationNotificationsEnabled,
|
||||
blockedKeys: appSettings?.blocked_keys ?? [],
|
||||
blockedNames: appSettings?.blocked_names ?? [],
|
||||
};
|
||||
const conversationPaneProps = {
|
||||
activeConversation,
|
||||
|
||||
@@ -398,8 +398,8 @@ export function ContactInfoPane({
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Block toggles (not applicable to repeaters) */}
|
||||
{!isRepeater && (onToggleBlockedKey || onToggleBlockedName) && (
|
||||
{/* Block toggles */}
|
||||
{(onToggleBlockedKey || onToggleBlockedName) && (
|
||||
<div className="px-5 py-3 border-b border-border space-y-2">
|
||||
{onToggleBlockedKey && (
|
||||
<button
|
||||
|
||||
@@ -110,6 +110,8 @@ interface SidebarProps {
|
||||
/** Legacy global sort order, used only to seed per-section local preferences. */
|
||||
legacySortOrder?: SortOrder;
|
||||
isConversationNotificationsEnabled?: (type: 'channel' | 'contact', id: string) => boolean;
|
||||
blockedKeys?: string[];
|
||||
blockedNames?: string[];
|
||||
}
|
||||
|
||||
type InitialSectionSortState = {
|
||||
@@ -153,7 +155,16 @@ export function Sidebar({
|
||||
favorites,
|
||||
legacySortOrder,
|
||||
isConversationNotificationsEnabled,
|
||||
blockedKeys = [],
|
||||
blockedNames = [],
|
||||
}: SidebarProps) {
|
||||
const isContactBlocked = useCallback(
|
||||
(c: Contact) =>
|
||||
blockedKeys.includes(c.public_key.toLowerCase()) ||
|
||||
(c.name != null && blockedNames.includes(c.name)),
|
||||
[blockedKeys, blockedNames]
|
||||
);
|
||||
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const initialSectionSortState = useMemo(loadInitialSectionSortOrders, []);
|
||||
const [sectionSortOrders, setSectionSortOrders] = useState(initialSectionSortState.orders);
|
||||
@@ -399,36 +410,42 @@ export function Sidebar({
|
||||
);
|
||||
|
||||
const filteredNonRepeaterContacts = useMemo(
|
||||
() =>
|
||||
query
|
||||
? sortedNonRepeaterContacts.filter(
|
||||
() => {
|
||||
const visible = sortedNonRepeaterContacts.filter((c) => !isContactBlocked(c));
|
||||
return query
|
||||
? visible.filter(
|
||||
(c) =>
|
||||
c.name?.toLowerCase().includes(query) || c.public_key.toLowerCase().includes(query)
|
||||
)
|
||||
: sortedNonRepeaterContacts,
|
||||
[sortedNonRepeaterContacts, query]
|
||||
: visible;
|
||||
},
|
||||
[sortedNonRepeaterContacts, query, isContactBlocked]
|
||||
);
|
||||
|
||||
const filteredRooms = useMemo(
|
||||
() =>
|
||||
query
|
||||
? sortedRooms.filter(
|
||||
() => {
|
||||
const visible = sortedRooms.filter((c) => !isContactBlocked(c));
|
||||
return query
|
||||
? visible.filter(
|
||||
(c) =>
|
||||
c.name?.toLowerCase().includes(query) || c.public_key.toLowerCase().includes(query)
|
||||
)
|
||||
: sortedRooms,
|
||||
[sortedRooms, query]
|
||||
: visible;
|
||||
},
|
||||
[sortedRooms, query, isContactBlocked]
|
||||
);
|
||||
|
||||
const filteredRepeaters = useMemo(
|
||||
() =>
|
||||
query
|
||||
? sortedRepeaters.filter(
|
||||
() => {
|
||||
const visible = sortedRepeaters.filter((c) => !isContactBlocked(c));
|
||||
return query
|
||||
? visible.filter(
|
||||
(c) =>
|
||||
c.name?.toLowerCase().includes(query) || c.public_key.toLowerCase().includes(query)
|
||||
)
|
||||
: sortedRepeaters,
|
||||
[sortedRepeaters, query]
|
||||
: visible;
|
||||
},
|
||||
[sortedRepeaters, query, isContactBlocked]
|
||||
);
|
||||
|
||||
// Expand sections while searching; restore prior collapse state when search ends.
|
||||
|
||||
Reference in New Issue
Block a user