mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
refactored hooks directory
This commit is contained in:
parent
efa3ba902d
commit
f76a5a4798
106 changed files with 122 additions and 144 deletions
17
src/hooks/node/useGrouppedComments.ts
Normal file
17
src/hooks/node/useGrouppedComments.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { IComment } from '~/redux/types';
|
||||
import { useMemo } from 'react';
|
||||
import { groupCommentsByUser } from '~/utils/fn';
|
||||
|
||||
export const useGrouppedComments = (
|
||||
comments: IComment[],
|
||||
order: 'ASC' | 'DESC',
|
||||
lastSeen?: string
|
||||
) =>
|
||||
useMemo(
|
||||
() =>
|
||||
(order === 'DESC' ? [...comments].reverse() : comments).reduce(
|
||||
groupCommentsByUser(lastSeen),
|
||||
[]
|
||||
),
|
||||
[comments, lastSeen, order]
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue