Feature: Node favourites (and ignores) (#618)

* Add favourite icon to node Avatar

* Favourites WIP

* Save isFavorite and isIgnored to device

* Fix spelling

* Clean up

* Always sort favorites first

* Add unread count to "Messages" top level menu

* Renaming, UI tweaks

* Add hook tests

* Handle undefined node better
This commit is contained in:
philon-
2025-05-13 08:45:24 -04:00
committed by GitHub
parent b2bb3baa01
commit 513a285fee
15 changed files with 699 additions and 256 deletions
+31
View File
@@ -0,0 +1,31 @@
import { useCallback } from "react";
import { useDevice } from "@core/stores/deviceStore.ts";
import { useToast } from "@core/hooks/useToast.ts";
interface IgnoreNodeOptions {
nodeNum: number;
isIgnored: boolean;
}
export function useIgnoreNode() {
const { updateIgnored, getNode } = useDevice();
const { toast } = useToast();
const updateIgnoredCB = useCallback(
({ nodeNum, isIgnored }: IgnoreNodeOptions) => {
const node = getNode(nodeNum);
if (!node) return;
updateIgnored(nodeNum, isIgnored);
toast({
title: `${isIgnored ? "Added" : "Removed"} ${
node?.user?.longName ?? "node"
} ${isIgnored ? "to" : "from"} ignore list`,
});
},
[updateIgnored, getNode],
);
return { updateIgnored: updateIgnoredCB };
}