From f3c3f3aa05bcf0afc9145f0636603eea74a914ec Mon Sep 17 00:00:00 2001 From: Aruseli Date: Sun, 28 Jul 2024 20:12:05 +0000 Subject: [PATCH] edits to the layout for mobile screens, solution to the hydration problem --- package-lock.json | 4 +- pages/index.tsx | 94 +++++++++++++++++++++++++++++++++------------- src/connection.tsx | 2 +- 3 files changed, 70 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2e8c379..3aa1faa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@deep-foundation/deepmemo-app", - "version": "0.0.7-dev.12", + "version": "0.0.7-dev.13", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@deep-foundation/deepmemo-app", - "version": "0.0.7-dev.12", + "version": "0.0.7-dev.13", "license": "Unlicense", "dependencies": { "@capacitor-community/background-geolocation": "^1.2.17", diff --git a/pages/index.tsx b/pages/index.tsx index 95b74b1..2c523d5 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -4,7 +4,7 @@ import { AccordionIcon, AccordionItem, AccordionPanel, - Box, Button, Card, CardBody, CardHeader, CircularProgress, CircularProgressLabel, FormControl, FormLabel, HStack, Heading, Input, InputGroup, InputRightElement, List, ListIcon, ListItem, Select, SimpleGrid, + Box, Button, Card, CardBody, CardHeader, CircularProgress, CircularProgressLabel, FormControl, FormLabel, HStack, Heading, IconButton, Input, InputGroup, InputRightElement, List, ListIcon, ListItem, Select, SimpleGrid, Slider, SliderFilledTrack, SliderMark, @@ -12,6 +12,7 @@ import { SliderTrack, Switch, Text, + useMediaQuery, useToast, } from '@chakra-ui/react'; import { CheckCircleIcon, WarningIcon, SpinnerIcon, CheckIcon, TriangleDownIcon } from '@chakra-ui/icons' @@ -49,6 +50,7 @@ import { EditorTextArea } from '@deep-foundation/deepcase/imports/editor/editor- import sortBy from 'lodash/sortBy'; import reverse from 'lodash/reverse'; import { deepEqual } from 'assert'; +import { AddIcon } from '@chakra-ui/icons' const { version: appVersion } = require('../package.json'); const { version: importsVersion } = require('../node_modules/@deep-foundation/deepmemo-imports/package.json'); @@ -130,11 +132,19 @@ const InstallerView = React.memo(function InstallerView({}: {}) { Installer - + - {!installer?.installing ? : } - {} + *:nth-child(1)': { + mr: '0.5rem' + } + }} + > + {!installer?.installing ? : } + {} + @@ -186,10 +196,11 @@ const InstallerView = React.memo(function InstallerView({}: {}) { - ApiKey ({installer?.['ApiKey']?.[0]?.value?.value || ''}) + ApiKey + ({installer?.['ApiKey']?.[0]?.value?.value || ''}) setApiKey(e.target.value)} /> - + @@ -213,10 +224,11 @@ const InstallerView = React.memo(function InstallerView({}: {}) { - TelegramToken ({installer?.['TelegramToken']?.[0]?.value?.value || ''}) + TelegramToken + ({installer?.['TelegramToken']?.[0]?.value?.value || ''}) setTelegramToken(e.target.value)} /> - + @@ -226,18 +238,22 @@ const InstallerView = React.memo(function InstallerView({}: {}) { Telegram bot for Deep.Memory ({installer?.['TelegramActive']?.[0]?.id || ''}) - - + + + + Deep.Memory ({installer?.['DeepmemoryActive']?.[0]?.id || ''}) - - + + + + - space ({installer?.['space']?.id || ''}) + space ({installer?.['space']?.id || ''}) @@ -251,6 +267,7 @@ const InstallerView = React.memo(function InstallerView({}: {}) { const Graph = React.memo(function Graph({ linkId, query = {} }: { linkId: Id; query?: any }) { const deep = useDeep(); const cyRef = useRef(); + const down450 = useMediaQuery('(max-width: 450px)'); const cytoViewportRef = useRefstarter<{ pan: { x: number; y: number; }; zoom: number }>(); const { data: links = [] }: { data?: Link[] } = deep.useDeepSubscription({ up: { parent_id: linkId || 0, tree_id: deep.idLocal('@deep-foundation/core', 'containTree') }, @@ -264,7 +281,7 @@ const Graph = React.memo(function Graph({ linkId, query = {} }: { linkId: Id; qu ...(query) }); return <> - {!!linkId && + {!!linkId && {deep?.linkId && } } ; @@ -404,7 +421,7 @@ const TemplatesViewCore = React.memo(function TemplatesView({ }: { }) { } }); return <> - + {templates.map(t => ())} ; @@ -413,8 +430,15 @@ const TemplatesViewCore = React.memo(function TemplatesView({ }: { }) { const TemplatesView = React.memo(function TemplatesView({ }: { }) { const deep = useDeep(); return <> - Templates - - + /> + + {!!deep?.linkId && } ; }); @@ -438,10 +463,11 @@ const TemplatesView = React.memo(function TemplatesView({ }: { }) { const DeviceView = React.memo(function DeviceView({ interval }: { interval: number }) { const deep = useDeep(); const device = useDevice(); + const down450 = useMediaQuery('(max-width: 450px)'); return <> Device {device?.id ? <>{device?.id} : <>{'id not defined'}} -
{JSON.stringify(device, null, 2)}
+
{JSON.stringify(device, null, 2)}
{deep?.linkId && device?.id && }
; @@ -452,7 +478,7 @@ const GeolocationView = React.memo(function GeolocationView({ interval }: { inte const geolocation = useGeolocation(); return <> Geolocation {geolocation?.position?.id ? <>{geolocation?.position?.id} : <>{'id not defined'}} <> - {!!geolocation.status ? : } + {!!geolocation.status ? : }
{JSON.stringify(geolocation, null, 2)}
{deep?.linkId && geolocation?.position?.id && } @@ -465,7 +491,7 @@ const BackgroundGeolocationView = React.memo(function BackgroundGeolocationView( const geolocation = useBackgroundGeolocation(); return <> Background Geolocation {geolocation?.position?.id ? <>{geolocation?.position?.id} : <>{'id not defined'}} - {!!geolocation.status ? : } + {!!geolocation.status ? : }
{JSON.stringify(geolocation, null, 2)}
{deep?.linkId && geolocation?.position?.id && } @@ -560,15 +586,15 @@ const VoiceView = React.memo(function VoiceView() { const record = await voice.stop(); }}>stop {voice.paused ? ( - + ) : ( - + )} ) : ( - + ) ) : ( - + )} ; }); @@ -598,6 +624,17 @@ export function OnlyConnectedAndAdmin({ children }: { children: any }) { export function OnlyInstalled({ children }: { children: any }) { const deep = useDeep(); const installer = useInstaller(); + const [hydrated, setHydrated] = useState(false); + + // hydration error problem solution + useEffect(() => { + setHydrated(true); + }, []); + + if (!hydrated) { + return null; + } + return <> {deep?.linkId && installer?.status ? children : Deep.Memo unavailable, {!deep?.linkId ? 'deep not connected' : 'not installed'}.} @@ -661,12 +698,15 @@ export default function Page() { + + setGeolocationManual(!v)}/> + setBackgroundGeolocationManual(!v)}/> diff --git a/src/connection.tsx b/src/connection.tsx index 49b2370..3fd2f51 100644 --- a/src/connection.tsx +++ b/src/connection.tsx @@ -35,7 +35,7 @@ export function Connection() { const [autoGuest, setAutoGuest] = useState(false); return ( - + {t('connection')}