Remove unnecessary useMemo from Profile, add ru translation for user.load-more

This commit is contained in:
esvyridov
2021-12-23 17:44:45 -06:00
committed by Umputun
parent 0bf5a91091
commit 250f730d5e
2 changed files with 7 additions and 6 deletions
+6 -5
View File
@@ -23,6 +23,8 @@ import type { Comment as CommentType, Theme } from 'common/types';
import styles from './profile.module.css';
import { Counter } from './components/counter';
const COMMENTS_LIMIT = 10;
async function signout() {
postMessageToParent({ profile: null, signout: true });
await logout();
@@ -32,7 +34,6 @@ async function signout() {
export function Profile() {
const intl = useIntl();
const rootRef = useRef<HTMLDivElement>(null);
const commentsLimit = useMemo(() => 10, []);
const user = useMemo(() => parseQuery(), []);
const [isCommentsLoading, setIsCommentsLoading] = useState(false);
const [error, setError] = useState(false);
@@ -40,14 +41,14 @@ export function Profile() {
const [commentsAmount, setCommentsAmount] = useState<number | null>(null);
const [commentsSkipCounts, setCommentsSkipCounts] = useState<number>(0);
const [isSigningOut, setSigningOut] = useState(false);
const isLoadMoreVisible = commentsAmount && commentsAmount > commentsSkipCounts + commentsLimit;
const isLoadMoreVisible = commentsAmount && commentsAmount > commentsSkipCounts + COMMENTS_LIMIT;
const fetchUserComments = useCallback(
async (skip: number = 0) => {
const { comments, count } = await getUserComments(user.id, { skip, limit: commentsLimit });
const { comments, count } = await getUserComments(user.id, { skip, limit: COMMENTS_LIMIT });
return { comments, count };
},
[user.id, commentsLimit]
[user.id]
);
const fetchUserCommentsOnMount = useCallback(async () => {
@@ -107,7 +108,7 @@ export function Profile() {
}
function handleLoadMore() {
const nextSkipCounts = commentsSkipCounts + commentsLimit;
const nextSkipCounts = commentsSkipCounts + COMMENTS_LIMIT;
setCommentsSkipCounts(nextSkipCounts);
fetchMoreUserComments(nextSkipCounts);
+1 -1
View File
@@ -159,7 +159,7 @@
"toolbar.unordered-list": "Добавить маркированный список",
"user.my-comments": "Мои комментарии",
"user.comments": "Комментарии",
"user.load-more": "Load more",
"user.load-more": "Загрузить ещё",
"vote.anonymous": "Анонимные пользователи не могут голосовать",
"vote.deleted": "Нельзя голосовать за удаленный комментарий",
"vote.guest": "Войдите, чтобы проголосовать",