mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-06-23 10:08:29 +07:00
removed messages reducer
This commit is contained in:
parent
82308d2a91
commit
5849e68258
61 changed files with 314 additions and 898 deletions
|
@ -1,4 +1,4 @@
|
|||
import { useCallback } from 'react';
|
||||
import { useCallback } from "react";
|
||||
|
||||
/** wraps text inside textarea with tags */
|
||||
export const useFormatWrapper = (onChange: (val: string) => void) => {
|
||||
|
|
17
src/hooks/messages/useMessages.ts
Normal file
17
src/hooks/messages/useMessages.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import useSWR from 'swr';
|
||||
import { API } from '~/constants/api';
|
||||
import { apiGetUserMessages } from '~/api/messages';
|
||||
import { IMessage } from '~/redux/types';
|
||||
|
||||
const getKey = (username: string): string | null => {
|
||||
return username ? `${API.USER.MESSAGES}/${username}` : null;
|
||||
};
|
||||
export const useMessages = (username: string) => {
|
||||
const { data, isValidating } = useSWR(getKey(username), async () =>
|
||||
apiGetUserMessages({ username })
|
||||
);
|
||||
|
||||
const messages: IMessage[] = data?.messages || [];
|
||||
|
||||
return { messages, isLoading: !data && isValidating };
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
import { useModalStore } from '~/store/modal/useModalStore';
|
||||
import { FC, useCallback, VFC } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
import { Dialog, DIALOG_CONTENT } from '~/constants/modal';
|
||||
import { IDialogProps } from '~/types/modal';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue