From c71853f7544cfd0842ed3c3790fb6200ff58ae59 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Sun, 20 Apr 2025 14:56:31 +0200 Subject: [PATCH] Remove isMobile check --- src/App.tsx | 218 +++++++++++++++++----------------------------------- 1 file changed, 72 insertions(+), 146 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 9bb5342..1c6913a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -118,9 +118,7 @@ import { import { useAppFullScreen } from './useAppFullscreen'; import { NotAuthenticated } from './ExtStates/NotAuthenticated'; import { handleGetFileFromIndexedDB } from './utils/indexedDB'; -import { CoreSyncStatus } from './components/CoreSyncStatus'; import { Wallets } from './Wallets'; -import { RandomSentenceGenerator } from './utils/seedPhrase/RandomSentenceGenerator'; import { useFetchResources } from './common/useFetchResources'; import { Tutorials } from './components/Tutorials/Tutorials'; import { useHandleTutorials } from './components/Tutorials/useHandleTutorials'; @@ -182,28 +180,6 @@ const defaultValues: MyContextInterface = { message: '', }, }; -export let isMobile = false; - -const isMobileDevice = () => { - const userAgent = navigator.userAgent || navigator.vendor || window.opera; - - if (/android/i.test(userAgent)) { - return true; // Android device - } - - if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { - return true; // iOS device - } - - return false; -}; - -if (isMobileDevice()) { - isMobile = true; - console.log('Running on a mobile device'); -} else { - console.log('Running on a desktop'); -} export const allQueues = { requestQueueCommentCount: requestQueueCommentCount, @@ -436,16 +412,20 @@ function App() { const [isOpenMinting, setIsOpenMinting] = useState(false); const { toggleFullScreen } = useAppFullScreen(setFullScreen); const generatorRef = useRef(null); + const exportSeedphrase = () => { const seedPhrase = generatorRef.current.parsedString; saveSeedPhraseToDisk(seedPhrase); }; + const passwordRef = useRef(null); + useEffect(() => { if (extState === 'wallet-dropped' && passwordRef.current) { passwordRef.current.focus(); } }, [extState]); + useEffect(() => { const isDevModeFromStorage = localStorage.getItem('isEnabledDevMode'); if (isDevModeFromStorage) { @@ -491,31 +471,38 @@ function App() { ); }; }, [toggleFullScreen]); + //resets for recoil const resetAtomSortablePinnedAppsAtom = useResetRecoilState( sortablePinnedAppsAtom ); + const resetAtomIsUsingImportExportSettingsAtom = useResetRecoilState( isUsingImportExportSettingsAtom ); const resetAtomCanSaveSettingToQdnAtom = useResetRecoilState( canSaveSettingToQdnAtom ); + const resetAtomSettingsQDNLastUpdatedAtom = useResetRecoilState( settingsQDNLastUpdatedAtom ); + const resetAtomSettingsLocalLastUpdatedAtom = useResetRecoilState( settingsLocalLastUpdatedAtom ); + const resetAtomOldPinnedAppsAtom = useResetRecoilState(oldPinnedAppsAtom); const resetAtomQMailLastEnteredTimestampAtom = useResetRecoilState( qMailLastEnteredTimestampAtom ); + const resetAtomMailsAtom = useResetRecoilState(mailsAtom); const resetGroupPropertiesAtom = useResetRecoilState(groupsPropertiesAtom); const resetLastPaymentSeenTimestampAtom = useResetRecoilState( lastPaymentSeenTimestampAtom ); + const resetAllRecoil = () => { resetAtomSortablePinnedAppsAtom(); resetAtomCanSaveSettingToQdnAtom(); @@ -528,34 +515,11 @@ function App() { resetGroupPropertiesAtom(); resetLastPaymentSeenTimestampAtom(); }; - useEffect(() => { - if (!isMobile) return; - // Function to set the height of the app to the viewport height - const resetHeight = () => { - const height = window.visualViewport - ? window.visualViewport.height - : window.innerHeight; - // Set the height to the root element (usually #root) - document.getElementById('root').style.height = height + 'px'; - setRootHeight(height + 'px'); - }; - // Set the initial height - resetHeight(); - - // Add event listeners for resize and visualViewport changes - window.addEventListener('resize', resetHeight); - window.visualViewport?.addEventListener('resize', resetHeight); - - // Clean up the event listeners when the component unmounts - return () => { - window.removeEventListener('resize', resetHeight); - window.visualViewport?.removeEventListener('resize', resetHeight); - }; - }, []); const handleSetGlobalApikey = (key) => { globalApiKey = key; }; + useEffect(() => { try { setIsLoading(true); @@ -1232,14 +1196,6 @@ function App() { // Handler for when the window gains focus const handleFocus = () => { setIsFocused(true); - if (isMobile) { - window.sendMessage('clearAllNotifications', {}).catch((error) => { - console.error( - 'Failed to clear notifications:', - error.message || 'An error occurred' - ); - }); - } }; // Handler for when the window loses focus @@ -1255,14 +1211,6 @@ function App() { const handleVisibilityChange = () => { if (document.visibilityState === 'visible') { setIsFocused(true); - if (isMobile) { - window.sendMessage('clearAllNotifications', {}).catch((error) => { - console.error( - 'Failed to clear notifications:', - error.message || 'An error occurred' - ); - }); - } } else { setIsFocused(false); } @@ -1315,7 +1263,7 @@ function App() { return ( - {isMobile && ( - - { - setIsOpenDrawerProfile(false); - }} - sx={{ - cursor: 'pointer', - }} - /> - - )} {desktopViewMode !== 'apps' && desktopViewMode !== 'dev' && desktopViewMode !== 'chat' && <>{renderProfileLeft()}} @@ -1609,51 +1539,46 @@ function App() { > - {!isMobile && ( - <> - - - LOG OUT - - } - placement="left" - arrow - sx={{ fontSize: '24' }} - slotProps={{ - tooltip: { - sx: { - color: theme.palette.text.primary, - backgroundColor: theme.palette.background.default, - }, - }, - arrow: { - sx: { - color: theme.palette.text.primary, - }, - }, + - { - logoutFunc(); - setIsOpenDrawerProfile(false); - }} - /> - - - )} + LOG OUT + + } + placement="left" + arrow + sx={{ fontSize: '24' }} + slotProps={{ + tooltip: { + sx: { + color: theme.palette.text.primary, + backgroundColor: theme.palette.background.default, + }, + }, + arrow: { + sx: { + color: theme.palette.text.primary, + }, + }, + }} + > + { + logoutFunc(); + setIsOpenDrawerProfile(false); + }} + /> + @@ -2009,7 +1934,7 @@ function App() { return ( - {!isMobile && renderProfile()} + renderProfile() )} {isOpenSendQort && isMainWindow && ( + +