cheogram-www
created pr with
cheogram-www/unread-filter.1
added cheogram-www/unread-filter.2
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 -3checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-www:unread-filter [rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-www:unread-filteradd comment to patch request:
ssh pr.pico.sh comment cheogram-www:unread-filter "lgtm!"
Patchset
cheogram-www/unread-filter.2
Combine unread and tag into filter.
Eric Roberts
2026-10-26T19:09:55ZSemantic diff summary
0 added,
4 modified,
0 signature changed,
0 removed
across 1 analyzed file
+11
-21
src/components/Chats.tsx
#
| ... | ... | @@ -13,7 +13,7 @@ import { | |
| 13 | 13 | } from "@mui/material"; | |
| 14 | 14 | import { QRCanvas, frontalCamera } from "qr/dom.js"; | |
| 15 | 15 | import { Virtuoso, VirtuosoHandle } from "react-virtuoso"; | |
| 16 | - | import { parseAsBoolean, useQueryState } from "nuqs"; | |
| 16 | + | import { useQueryState } from "nuqs"; | |
| 17 | 17 | import { useState, useEffect, useRef, useCallback, useContext } from "react"; | |
| 18 | 18 | import { | |
| 19 | 19 | Outlet, |
| ... | ... | @@ -65,11 +65,7 @@ export const Chats = () => { | |
| 65 | 65 | const navigate = useNavigate(); | |
| 66 | 66 | const [searchParams] = useSearchParams(); | |
| 67 | 67 | 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"); | |
| 73 | 69 | const { persistence, client, status, setStatus, logout } = useOutletContext<{ | |
| 74 | 70 | persistence: borogove.Persistence & borogove.persistence.KeyValueStore; | |
| 75 | 71 | client: borogove.Client; |
| ... | ... | @@ -311,9 +307,12 @@ export const Chats = () => { | |
| 311 | 307 | } | |
| 312 | 308 | } | |
| 313 | 309 | } | |
| 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 | + | }); | |
| 317 | 316 | }; | |
| 318 | 317 | ||
| 319 | 318 | const [searchResultLimit, setSearchResultLimit] = useState(5); |
| ... | ... | @@ -617,19 +616,10 @@ export const Chats = () => { | |
| 617 | 616 | </AwaitOnce> | |
| 618 | 617 | <select | |
| 619 | 618 | 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) | |
| 622 | 622 | } | |
| 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 | - | }} | |
| 633 | 623 | > | |
| 634 | 624 | <option value="all">All Chats</option> | |
| 635 | 625 | <option value="unread">Unread</option> |