diff --git a/fe/.eslintrc.cjs b/fe/.eslintrc.cjs index f79f9323..be5c5f9c 100644 --- a/fe/.eslintrc.cjs +++ b/fe/.eslintrc.cjs @@ -507,7 +507,7 @@ const eslintPluginVue = { // as of eslint-plugin-vue@9.19.2 }], 'vue/match-component-import-name': 'error', 'vue/define-props-declaration': 'error', - 'vue/define-emits-declaration': 'error', + 'vue/define-emits-declaration': ['error', 'type-literal'], 'vue/no-required-prop-with-default': 'error', 'vue/v-on-handler-style': ['error', 'inline-function'], 'vue/multiline-ternary': 'error', diff --git a/fe/src/api/index.d.ts b/fe/src/api/index.d.ts index 63fb52cc..62b31c10 100644 --- a/fe/src/api/index.d.ts +++ b/fe/src/api/index.d.ts @@ -44,7 +44,6 @@ export type ApiStatsForumPostCount = Api<{ }>; export type Cursor = string; -interface CursorPaginationQueryParam { cursor?: Cursor } interface CursorPagination { pages: { currentCursor: Cursor, @@ -55,7 +54,7 @@ interface CursorPagination { export type ApiUsers = Api< CursorPagination & { users: User[] }, - CursorPaginationQueryParam & SelectUserParams & { gender?: UserGenderQueryParam } + SelectUserParams & { gender?: UserGenderQueryParam } >; export type JsonString = string; @@ -72,4 +71,4 @@ export type ApiPosts = Api }>, users: User[] -}, CursorPaginationQueryParam & { query: JsonString }>; +}, { query: JsonString }>; diff --git a/fe/src/api/index.ts b/fe/src/api/index.ts index 5b6c355c..0492315f 100644 --- a/fe/src/api/index.ts +++ b/fe/src/api/index.ts @@ -1,6 +1,6 @@ import type { Api, ApiError, ApiForums, ApiPosts, ApiStatsForumPostCount, ApiStatus, ApiUsers, Cursor, CursorPagination } from '@/api/index.d'; -import type { MaybeRefOrGetter, Ref } from 'vue'; -import type { InfiniteData, QueryKey } from '@tanstack/vue-query'; +import type { Ref } from 'vue'; +import type { InfiniteData, QueryKey, UseInfiniteQueryOptions, UseQueryOptions } from '@tanstack/vue-query'; import { useInfiniteQuery, useQuery } from '@tanstack/vue-query'; import nprogress from 'nprogress'; import { stringify } from 'qs'; @@ -86,18 +86,23 @@ const useApi = < TResponse = TApi['response'], TQueryParam = TApi['queryParam']> (endpoint: string, queryFn: QueryFunctions) => - (queryParam?: Ref, enabled?: MaybeRefOrGetter) => + (queryParam?: Ref, options?: Partial>) => useQuery({ queryKey: [endpoint, queryParam], queryFn: async () => queryFn(`/${endpoint}`, queryParam?.value), - enabled + ...options }); const useApiWithCursor = < TApi extends Api, TResponse = TApi['response'] & CursorPagination, TQueryParam = TApi['queryParam']> (endpoint: string, queryFn: QueryFunctions) => - (queryParam?: Ref, enabled?: MaybeRefOrGetter) => + (queryParam?: Ref, options?: Partial, + TResponse & CursorPagination, + QueryKey, Cursor + >>) => useInfiniteQuery< TResponse & CursorPagination, ApiErrorClass, InfiniteData, @@ -108,9 +113,9 @@ const useApiWithCursor = < `/${endpoint}`, { ...queryParam?.value as TQueryParam, cursor: pageParam === '' ? undefined : pageParam } ), - initialPageParam: '', getNextPageParam: lastPage => lastPage.pages.nextCursor, - enabled + initialPageParam: '', + ...options }); export const useApiForums = () => useApi('forums', queryFunction)(); diff --git a/fe/src/components/Post/renderers/RendererTable.vue b/fe/src/components/Post/renderers/RendererTable.vue index 6a18dd4e..504b1c39 100644 --- a/fe/src/components/Post/renderers/RendererTable.vue +++ b/fe/src/components/Post/renderers/RendererTable.vue @@ -49,11 +49,12 @@