cheogram-www

created pr with cheogram-www/unread-filter.1 on 2026-10-26T01:58:16Z · by 9e834e0d
added cheogram-www/unread-filter.2 on 2026-10-26T19:27:04Z · by 3c31bc8c
1: 9d343f3 = 1: efc44ba Allow filtering by unread
-: ------- > 2: 2da6059 Combine unread and tag into filter.
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-www:unread-filter | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-www:unread-filter [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-www:unread-filter
add comment to patch request:
ssh pr.pico.sh comment cheogram-www:unread-filter "lgtm!"
+11 -21 src/components/Chats.tsx #
......@@ -13,7 +13,7 @@ import {
1313 } from "@mui/material";
1414 import { QRCanvas, frontalCamera } from "qr/dom.js";
1515 import { Virtuoso, VirtuosoHandle } from "react-virtuoso";
16-import { parseAsBoolean, useQueryState } from "nuqs";
16+import { useQueryState } from "nuqs";
1717 import { useState, useEffect, useRef, useCallback, useContext } from "react";
1818 import {
1919 Outlet,
......@@ -65,11 +65,7 @@ export const Chats = () => {
6565 const navigate = useNavigate();
6666 const [searchParams] = useSearchParams();
6767 const [searchQ, setSearchQ] = useQueryState("q");
68- const [searchTag, setSearchTag] = useQueryState("tag");
69- const [searchUnread, setSearchUnread] = useQueryState(
70- "unread",
71- parseAsBoolean.withDefault(false),
72- );
68+ const [searchFilter, setSearchFilter] = useQueryState("filter");
7369 const { persistence, client, status, setStatus, logout } = useOutletContext<{
7470 persistence: borogove.Persistence & borogove.persistence.KeyValueStore;
7571 client: borogove.Client;
......@@ -311,9 +307,12 @@ export const Chats = () => {
311307 }
312308 }
313309 }
314- return results
315- .filter((c) => !searchTag || c.getTags().includes(searchTag))
316- .filter((c) => !searchUnread || c.unreadCount() > 0);
310+ return results.filter((c) => {
311+ if (searchFilter === "unread") return c.unreadCount() > 0;
312+ if (searchFilter?.startsWith("tag:"))
313+ return c.getTags().includes(searchFilter.slice(4));
314+ return true;
315+ });
317316 };
318317
319318 const [searchResultLimit, setSearchResultLimit] = useState(5);
......@@ -617,19 +616,10 @@ export const Chats = () => {
617616 </AwaitOnce>
618617 <select
619618 id="tag-nav"
620- value={
621- searchUnread ? "unread" : searchTag ? `tag:${searchTag}` : "all"
619+ value={searchFilter ?? "all"}
620+ onChange={(e) =>
621+ setSearchFilter(e.target.value === "all" ? null : e.target.value)
622622 }
623- onChange={(e) => {
624- const value = e.target.value;
625- if (value.startsWith("tag:")) {
626- setSearchUnread(false);
627- setSearchTag(value.slice("tag:".length));
628- } else {
629- setSearchTag(null);
630- setSearchUnread(value === "unread");
631- }
632- }}
633623 >
634624 <option value="all">All Chats</option>
635625 <option value="unread">Unread</option>
Back to top