email box empty styling
This commit is contained in:
parent
1ee8a58117
commit
5cb49f4cb1
19 changed files with 547 additions and 67 deletions
26
frontend/src/hooks/useMailboxMaturity.js
Normal file
26
frontend/src/hooks/useMailboxMaturity.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { useEffect, useState } from "react";
|
||||
|
||||
function storageKey(accountId) {
|
||||
return `agmail_had_mail_${accountId}`;
|
||||
}
|
||||
|
||||
export function useMailboxMaturity(account, emails, loading) {
|
||||
const [hadMail, setHadMail] = useState(() => {
|
||||
if (!account?.id) return false;
|
||||
return localStorage.getItem(storageKey(account.id)) === "1";
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!account?.id) return;
|
||||
if (!loading && emails.length > 0) {
|
||||
localStorage.setItem(storageKey(account.id), "1");
|
||||
setHadMail(true);
|
||||
}
|
||||
}, [account?.id, emails.length, loading]);
|
||||
|
||||
const isBrandNew = Boolean(
|
||||
account?.id && !loading && emails.length === 0 && !hadMail,
|
||||
);
|
||||
|
||||
return { isBrandNew, hadMail };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue