From 34d8f2f8442978199b612f804b7d3e5c93235ed8 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Sat, 12 Apr 2025 17:51:03 +0200 Subject: [PATCH] Format file --- src/components/QMailStatus.tsx | 87 ++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/src/components/QMailStatus.tsx b/src/components/QMailStatus.tsx index cb1642a..0485240 100644 --- a/src/components/QMailStatus.tsx +++ b/src/components/QMailStatus.tsx @@ -1,31 +1,43 @@ -import React, { useMemo } from 'react' -import QMailLogo from '../assets/QMailLogo.png' -import { useRecoilState } from 'recoil' -import { mailsAtom, qMailLastEnteredTimestampAtom } from '../atoms/global' -import { isLessThanOneWeekOld } from './Group/QMailMessages' -import { ButtonBase, Tooltip } from '@mui/material' -import { executeEvent } from '../utils/events' -export const QMailStatus = () => { - const [lastEnteredTimestamp, setLastEnteredTimestamp] = useRecoilState(qMailLastEnteredTimestampAtom) - const [mails, setMails] = useRecoilState(mailsAtom) +import { useMemo } from 'react'; +import QMailLogo from '../assets/QMailLogo.png'; +import { useRecoilState } from 'recoil'; +import { mailsAtom, qMailLastEnteredTimestampAtom } from '../atoms/global'; +import { isLessThanOneWeekOld } from './Group/QMailMessages'; +import { ButtonBase, Tooltip } from '@mui/material'; +import { executeEvent } from '../utils/events'; - const hasNewMail = useMemo(()=> { - if(mails?.length === 0) return false - const latestMail = mails[0] - if(!lastEnteredTimestamp && isLessThanOneWeekOld(latestMail?.created)) return true - if((lastEnteredTimestamp < latestMail?.created) && isLessThanOneWeekOld(latestMail?.created)) return true - return false - }, [lastEnteredTimestamp, mails]) +export const QMailStatus = () => { + const [lastEnteredTimestamp, setLastEnteredTimestamp] = useRecoilState( + qMailLastEnteredTimestampAtom + ); + const [mails, setMails] = useRecoilState(mailsAtom); + + const hasNewMail = useMemo(() => { + if (mails?.length === 0) return false; + const latestMail = mails[0]; + if (!lastEnteredTimestamp && isLessThanOneWeekOld(latestMail?.created)) + return true; + if ( + lastEnteredTimestamp < latestMail?.created && + isLessThanOneWeekOld(latestMail?.created) + ) + return true; + return false; + }, [lastEnteredTimestamp, mails]); return ( - { - executeEvent("addTab", { data: { service: 'APP', name: 'q-mail' } }); - executeEvent("open-apps-mode", { }); - setLastEnteredTimestamp(Date.now()) - }} style={{ - position: 'relative' - }}> + { + executeEvent('addTab', { data: { service: 'APP', name: 'q-mail' } }); + executeEvent('open-apps-mode', {}); + setLastEnteredTimestamp(Date.now()); + }} + style={{ + position: 'relative', + }} + > {hasNewMail && ( -
{ height: '15px', width: '15px', borderRadius: '50%', - outline: '1px solid white' - }} /> + outline: '1px solid white', + }} + /> )} Q-MAIL} + title={ + + Q-MAIL + + } placement="left" arrow - sx={{ fontSize: "24" }} + sx={{ fontSize: '24' }} slotProps={{ tooltip: { sx: { - color: "#ffffff", - backgroundColor: "#444444", + color: '#ffffff', + backgroundColor: '#444444', }, }, arrow: { sx: { - color: "#444444", + color: '#444444', }, }, }} > - - ) -} + + ); +};