Files
ncd-fe/packages/pl-fe/src/queries/timelines/use-events-lists.ts
nicole mikołajczyk 9f98b5b07d nicolium: oxlint and oxfmt migration, remove eslint
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
2026-02-15 13:30:55 +01:00

38 lines
1.1 KiB
TypeScript

import { useInfiniteQuery } from '@tanstack/react-query';
import { makePaginatedResponseQueryOptions } from '../utils/make-paginated-response-query-options';
import { minifyStatusList } from '../utils/minify-list';
const recentEventsQueryOptions = makePaginatedResponseQueryOptions(
['statusLists', 'recentEvents'],
(client) =>
client.timelines
.publicTimeline({
only_events: true,
})
.then((res) => ({
...res,
items: res.items.filter(({ event }) => event),
}))
.then(minifyStatusList),
)();
const useRecentEventsTimeline = () =>
useInfiniteQuery({
...recentEventsQueryOptions,
staleTime: 5 * 60 * 1000, // 5 minutes
});
const joinedEventsQueryOptions = makePaginatedResponseQueryOptions(
['statusLists', 'joinedEvents'],
(client) => client.events.getJoinedEvents().then(minifyStatusList),
)();
const useJoinedEventsTimeline = () =>
useInfiniteQuery({
...joinedEventsQueryOptions,
staleTime: 5 * 60 * 1000, // 5 minutes
});
export { useRecentEventsTimeline, useJoinedEventsTimeline };