diff --git a/src/components/layout/footer/GatewayCount.tsx b/src/components/layout/footer/GatewayCount.tsx index df6c40cdb8..021247cd31 100644 --- a/src/components/layout/footer/GatewayCount.tsx +++ b/src/components/layout/footer/GatewayCount.tsx @@ -1,6 +1,7 @@ 'use client' import { useQuery } from '@tanstack/react-query' +import { sleep } from 'openai/core' import { useOnlineCount } from '~/atoms' import { useSocketIsConnect } from '~/atoms/hooks' @@ -115,51 +116,46 @@ const RoomsInfo = () => { const { data } = useQuery({ queryKey: ['rooms'], refetchOnMount: true, - queryFn: () => { - return apiClient.activity - .getRoomsInfo() - .then((res) => res.$serialized) - .then((data) => { - const result = [] as { - path: string - title: string - count: number - }[] - - const morphArticleIdToRoomName = (id: string) => `article_${id}` - data.objects.notes.forEach((note) => { - result.push({ - path: routeBuilder(Routes.Note, { - id: note.nid, - }), - title: note.title, - count: data.roomCount[morphArticleIdToRoomName(note.id)], - }) - }) - - data.objects.posts.forEach((post) => { - result.push({ - path: routeBuilder(Routes.Post, { - category: post.category.slug, - slug: post.slug, - }), - title: post.title, - count: data.roomCount[morphArticleIdToRoomName(post.id)], - }) - }) - - data.objects.pages.forEach((page) => { - result.push({ - path: routeBuilder(Routes.Page, { - slug: page.slug, - }), - title: page.title, - count: data.roomCount[morphArticleIdToRoomName(page.id)], - }) - }) - - return result.sort((a, b) => b.count - a.count) + staleTime: 1000 * 10, + queryFn: async () => { + await sleep(1000) + const res = await apiClient.activity.getRoomsInfo() + const data = res.$serialized + const result = [] as { + path: string + title: string + count: number + }[] + const morphArticleIdToRoomName = (id: string) => `article_${id}` + data.objects.notes.forEach((note) => { + result.push({ + path: routeBuilder(Routes.Note, { + id: note.nid, + }), + title: note.title, + count: data.roomCount[morphArticleIdToRoomName(note.id)], + }) + }) + data.objects.posts.forEach((post) => { + result.push({ + path: routeBuilder(Routes.Post, { + category: post.category.slug, + slug: post.slug, + }), + title: post.title, + count: data.roomCount[morphArticleIdToRoomName(post.id)], + }) + }) + data.objects.pages.forEach((page) => { + result.push({ + path: routeBuilder(Routes.Page, { + slug: page.slug, + }), + title: page.title, + count: data.roomCount[morphArticleIdToRoomName(page.id)], }) + }) + return result.sort((a, b) => b.count - a.count) }, }) diff --git a/src/components/modules/note/NoteActionAside.tsx b/src/components/modules/note/NoteActionAside.tsx index 21e8c5e0a5..32939d0839 100644 --- a/src/components/modules/note/NoteActionAside.tsx +++ b/src/components/modules/note/NoteActionAside.tsx @@ -35,7 +35,7 @@ export const NoteBottomBarAction: Component = () => { const isMobile = useIsMobile() if (!isMobile) return null return ( -