diff --git a/frontend/.size-limit.js b/frontend/.size-limit.js index 92941ff8..aeea1725 100644 --- a/frontend/.size-limit.js +++ b/frontend/.size-limit.js @@ -8,7 +8,7 @@ module.exports = [ path: 'public/remark.js', }, { - limit: '45 KB', + limit: '43 KB', path: 'public/last-comments.js', }, { diff --git a/frontend/app/common/api.getLastComments.ts b/frontend/app/common/api.getLastComments.ts new file mode 100644 index 00000000..b5625cd0 --- /dev/null +++ b/frontend/app/common/api.getLastComments.ts @@ -0,0 +1,6 @@ +import { Comment } from './types'; +import fetcher from './fetcher'; + +export default function getLastComments(siteId: string, max: number): Promise { + return fetcher.get(`/last/${max}?site=${siteId}`); +} diff --git a/frontend/app/common/api.ts b/frontend/app/common/api.ts index 114f606b..96c89812 100644 --- a/frontend/app/common/api.ts +++ b/frontend/app/common/api.ts @@ -4,7 +4,6 @@ import { Config, Comment, Tree, User, BlockedUser, Sorting, AuthProvider, BlockT import fetcher from './fetcher'; /* common */ - const __loginAnonymously = (username: string): Promise => { const url = `/auth/anonymous/login?user=${encodeURIComponent(username)}&aud=${siteId}&from=${encodeURIComponent( location.origin + location.pathname + '?selfClose' @@ -76,9 +75,6 @@ export const getPostComments = (sort: Sorting): Promise => withCredentials: true, }); -export const getLastComments = (siteId: string, max: number): Promise => - fetcher.get(`/last/${max}?site=${siteId}`); - export const getCommentsCount = (siteId: string, urls: string[]): Promise<{ url: string; count: number }[]> => fetcher.post({ url: `/counts?site=${siteId}`, @@ -302,7 +298,6 @@ export default { logOut, getConfig, getPostComments, - getLastComments, getCommentsCount, getComment, getUserComments, diff --git a/frontend/app/common/constants.ts b/frontend/app/common/constants.ts index 671d4f24..4fd2de13 100644 --- a/frontend/app/common/constants.ts +++ b/frontend/app/common/constants.ts @@ -6,8 +6,6 @@ export const API_BASE = configConstant.API_BASE; export const NODE_ID = configConstant.NODE_ID; export const COMMENT_NODE_CLASSNAME_PREFIX = configConstant.COMMENT_NODE_CLASSNAME_PREFIX; export const LAST_COMMENTS_NODE_CLASSNAME = 'remark42__last-comments'; -export const DEFAULT_LAST_COMMENTS_MAX = 15; -export const DEFAULT_MAX_COMMENT_SIZE = 1000; export const MAX_SHOWN_ROOT_COMMENTS = 10; export const DEFAULT_SORT: Sorting = '-active'; diff --git a/frontend/app/components/list-comments/list-comments.tsx b/frontend/app/components/list-comments/list-comments.tsx index aeae766b..2eafd3de 100644 --- a/frontend/app/components/list-comments/list-comments.tsx +++ b/frontend/app/components/list-comments/list-comments.tsx @@ -1,20 +1,16 @@ /** @jsx createElement */ -import { createElement } from 'preact'; +import { createElement, FunctionComponent } from 'preact'; import { NODE_ID } from '@app/common/constants'; import { Comment as CommentType } from '@app/common/types'; - import { Comment } from '@app/components/comment'; -interface Props { - comments: CommentType[]; -} - -export const ListComments = ({ comments = [] }: Props) => ( +export const ListComments: FunctionComponent<{ comments: CommentType[] }> = ({ comments = [] }) => (
{comments.map(comment => (