Skip to content

Commit 9b00e5b

Browse files
feat: group list for the moment
1 parent b960551 commit 9b00e5b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • src/app/dashboard/(active)/telegram/groups

src/app/dashboard/(active)/telegram/groups/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use client"
2-
import { useMutation, useQueryClient } from "@tanstack/react-query"
2+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
33
import { ArrowLeft, Copy, Pen, Search, X } from "lucide-react"
44
import Link from "next/link"
55
import { useState } from "react"
@@ -19,8 +19,9 @@ export default function TgGroups() {
1919
const trpc = useTRPC()
2020
const qc = useQueryClient()
2121
const queryOpts = trpc.tg.groups.search.queryOptions({ query, limit: 20, showHidden: true })
22+
const { data: allGroups, isLoading } = useQuery(trpc.tg.groups.getAll.queryOptions())
2223

23-
const [rows, setRows] = useState<Groups>([])
24+
const [rows, setRows] = useState<Groups>(!isLoading ? (allGroups ?? []) : [])
2425

2526
async function search() {
2627
const res = await qc.fetchQuery(queryOpts)
@@ -42,7 +43,7 @@ export default function TgGroups() {
4243
}
4344

4445
function reset() {
45-
setRows([])
46+
setRows(allGroups ?? [])
4647
setQuery("")
4748
}
4849

0 commit comments

Comments
 (0)