mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Email app upgrades WIP
This commit is contained in:
1 parent
c2510266f8
commit
ff4381fa01
12 files changed
+272
-132
No files matched your search
@@ -1,8 +1,18 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { IEmail } from '../../../common/typings/email';
|
||||
import { emailState } from './state';
|
||||
|
||||
export const useEmail = () => {
|
||||
const emails = useRecoilValue(emailState.emails);
|
||||
const inbox = useRecoilValue(emailState.inbox);
|
||||
const sent = useRecoilValue(emailState.sent);
|
||||
const myEmail = useRecoilValue(emailState.myEmail);
|
||||
|
||||
return { emails };
|
||||
const allEmails = useMemo(() => [...(sent || []), ...(inbox || [])], [inbox, sent]);
|
||||
|
||||
const isMine = (email: IEmail) => email.sender === myEmail;
|
||||
|
||||
const getEmailById = (id: number) => allEmails.find((e) => e.id === id) || null;
|
||||
|
||||
return { inbox, sent, myEmail, isMine, getEmailById };
|
||||
};
|
||||
Reference in new issue
Block a user