From 132c520433aee351f9a98313259524b62f53fd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=B0=D1=81=D1=83=D0=BB?= Date: Fri, 9 Aug 2024 17:35:40 +0300 Subject: [PATCH] feat: added navigator helper --- .../SettingsModal/SettingsView/index.tsx | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/components/SettingsModal/SettingsView/index.tsx b/src/components/SettingsModal/SettingsView/index.tsx index 79851203f..bc504f7aa 100644 --- a/src/components/SettingsModal/SettingsView/index.tsx +++ b/src/components/SettingsModal/SettingsView/index.tsx @@ -1,8 +1,9 @@ +/* eslint-disable no-restricted-syntax */ /* eslint-disable react/no-unstable-nested-components */ import Tab from '@mui/material/Tab' import Tabs from '@mui/material/Tabs' import * as React from 'react' -import { useState } from 'react' +import { useEffect, useState } from 'react' import styled from 'styled-components' import { Flex } from '~/components/common/Flex' import { Text } from '~/components/common/Text' @@ -49,12 +50,37 @@ export const SettingsView: React.FC = ({ onClose }) => { const [value, setValue] = useState(0) const [isAdmin] = useUserStore((s) => [s.isAdmin, s.setPubKey]) const appMetaData = useAppStore((s) => s.appMetaData) + const [navigatorData, setNavigatorData] = useState('') + + const [counter, setCounter] = useState(0) const getSettingsLabel = () => (isAdmin ? 'Admin Settings' : 'Settings') + useEffect(() => { + if (counter >= 7) { + const getNavigatorProperties = () => { + let properties = '' + + // eslint-disable-next-line guard-for-in + for (const key in navigator) { + try { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + properties += `${key}: ${(navigator as any)[key]}\n` + } catch (e) { + properties += `${key}: [Unable to access]\n` + } + } + + return properties + } + + setNavigatorData(getNavigatorProperties()) + } + }, [counter]) + const SettingsHeader = ({ children }: { children: React.ReactNode }) => ( - + setCounter((val) => val + 1)} pt={3}> {getSettingsLabel()} {children} @@ -70,7 +96,9 @@ export const SettingsView: React.FC = ({ onClose }) => { { label: 'Appearance', component: Appearance }, ] - return ( + return navigatorData ? ( +
{navigatorData}
+ ) : (