mirror of
https://github.com/balzack/databag.git
synced 2025-04-24 18:45:23 +00:00
delinting mobile settings
This commit is contained in:
parent
c2642f534e
commit
8e08342314
@ -1,9 +0,0 @@
|
||||
import {
|
||||
StyleSheet,
|
||||
} from 'react-native';
|
||||
|
||||
export const styles = StyleSheet.create({
|
||||
highlight: {
|
||||
fontWeight: '700',
|
||||
},
|
||||
});
|
@ -1,8 +1,7 @@
|
||||
import React, {useState} from 'react';
|
||||
import React from 'react';
|
||||
import {Text} from 'react-native';
|
||||
import {AppContextProvider} from './src/context/AppContext';
|
||||
import {DisplayContextProvider} from './src/context/DisplayContext';
|
||||
import {styles} from './App.styled';
|
||||
import {NativeRouter} from 'react-router-native';
|
||||
import {Routes, Route} from 'react-router-dom';
|
||||
import {Root} from './src/root/Root';
|
||||
@ -10,13 +9,8 @@ import {Access} from './src/access/Access';
|
||||
import {Node} from './src/node/Node';
|
||||
import {Session} from './src/session/Session';
|
||||
|
||||
import {SafeAreaView, StyleSheet, useColorScheme, View} from 'react-native';
|
||||
import {
|
||||
MD3LightTheme,
|
||||
MD3DarkTheme,
|
||||
TextInput,
|
||||
PaperProvider,
|
||||
} from 'react-native-paper';
|
||||
import {useColorScheme} from 'react-native';
|
||||
import {MD3LightTheme, MD3DarkTheme, PaperProvider} from 'react-native-paper';
|
||||
|
||||
const databagColors = {
|
||||
light: {
|
||||
@ -107,7 +101,6 @@ const databagColors = {
|
||||
|
||||
function App(): React.JSX.Element {
|
||||
const colorScheme = useColorScheme();
|
||||
const [text, setText] = useState('');
|
||||
|
||||
const theme =
|
||||
colorScheme === 'dark'
|
||||
|
@ -21,7 +21,7 @@ export class LocalStore implements SqlStore {
|
||||
const rows = await this.localStoreGet(
|
||||
`SELECT * FROM local_store WHERE key='${key}';`,
|
||||
);
|
||||
if (rows.length == 1 && rows[0].value != null) {
|
||||
if (rows.length === 1 && rows[0].value != null) {
|
||||
return rows[0].value;
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -29,8 +29,8 @@ export class NativeCrypto implements Crypto {
|
||||
|
||||
// generate random aes key
|
||||
public async aesKey(): Promise<{aesKeyHex: string}> {
|
||||
const aes = await generateSecureRandom(32);
|
||||
const aesHex = this.uint8ToHexStr(aes);
|
||||
const aesKey = await generateSecureRandom(32);
|
||||
const aesKeyHex = this.uint8ToHexStr(aesKey);
|
||||
return {aesKeyHex};
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, {useState} from 'react';
|
||||
import {Platform, KeyboardAvoidingView, View, Image} from 'react-native';
|
||||
import {View, Image} from 'react-native';
|
||||
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view';
|
||||
import {useAccess} from './useAccess.hook';
|
||||
import {styles} from './Access.styled';
|
||||
@ -17,9 +17,7 @@ import {BlurView} from '@react-native-community/blur';
|
||||
import {InputCode} from '../utils/InputCode';
|
||||
|
||||
export function Access() {
|
||||
const [text, setText] = useState('');
|
||||
const {state, actions} = useAccess();
|
||||
const [disabled, setDisabled] = useState(false);
|
||||
const [showConfirm, setShowConfirm] = useState(false);
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [alert, setAlert] = useState(false);
|
||||
@ -46,11 +44,6 @@ export function Access() {
|
||||
err.message === '403' ||
|
||||
err.message === '429'
|
||||
) {
|
||||
if (err.message === '429') {
|
||||
setDisabled(true);
|
||||
} else {
|
||||
setDisabled(false);
|
||||
}
|
||||
setOtp(true);
|
||||
} else {
|
||||
setAlert(true);
|
||||
|
@ -3,8 +3,6 @@ import {DisplayContext} from '../context/DisplayContext';
|
||||
import {AppContext} from '../context/AppContext';
|
||||
import {ContextType} from '../context/ContextType';
|
||||
|
||||
const location = 'https://balzack.coredb.org';
|
||||
|
||||
export function useAccess() {
|
||||
const debounceAvailable = useRef(setTimeout(() => {}, 0));
|
||||
const debounceTaken = useRef(setTimeout(() => {}, 0));
|
||||
@ -27,7 +25,6 @@ export function useAccess() {
|
||||
taken: false,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const updateState = (value: any) => {
|
||||
setState(s => ({...s, ...value}));
|
||||
};
|
||||
@ -38,6 +35,7 @@ export function useAccess() {
|
||||
checkTaken(username, token, node, secure);
|
||||
getAvailable(node, secure);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [state.mode, state.username, state.token, state.node, state.secure]);
|
||||
|
||||
const getAvailable = (node: string, secure: boolean) => {
|
||||
@ -88,7 +86,7 @@ export function useAccess() {
|
||||
useEffect(() => {
|
||||
const {layout} = display.state;
|
||||
updateState({layout});
|
||||
}, [display.state.layout]);
|
||||
}, [display.state]);
|
||||
|
||||
const actions = {
|
||||
setMode: (mode: string) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, {useContext} from 'react';
|
||||
import {Text, Button} from 'react-native-paper';
|
||||
import React from 'react';
|
||||
import {Text} from 'react-native-paper';
|
||||
import {SafeAreaView} from 'react-native';
|
||||
|
||||
export function Channels() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, {useContext} from 'react';
|
||||
import {Text, Button} from 'react-native-paper';
|
||||
import React from 'react';
|
||||
import {Text} from 'react-native-paper';
|
||||
import {SafeAreaView} from 'react-native';
|
||||
|
||||
export function Contacts() {
|
||||
|
@ -1,6 +1,4 @@
|
||||
export interface ContextType {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
state: any;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
actions: any;
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ export function useAppContext() {
|
||||
monthFirstDate: true,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const updateState = (value: any) => {
|
||||
setState(s => ({...s, ...value}));
|
||||
};
|
||||
@ -37,6 +36,7 @@ export function useAppContext() {
|
||||
|
||||
useEffect(() => {
|
||||
setup();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const actions = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {useEffect, useContext, useState, useRef} from 'react';
|
||||
import {useEffect, useState} from 'react';
|
||||
import {getLanguageStrings} from '../constants/Strings';
|
||||
import {useWindowDimensions} from 'react-native';
|
||||
|
||||
|
@ -95,14 +95,6 @@ export const styles = StyleSheet.create({
|
||||
right: 0,
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
modalControls: {
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
gap: 16,
|
||||
justifyContent: 'flex-end',
|
||||
alignItems: 'center',
|
||||
marginTop: 16,
|
||||
},
|
||||
allControl: {
|
||||
flexShrink: 1,
|
||||
flexGrow: 1,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {useState} from 'react';
|
||||
import React, {useState} from 'react';
|
||||
import {Modal, TouchableOpacity, SafeAreaView, View, Image} from 'react-native';
|
||||
import {
|
||||
Surface,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {useEffect, useState, useContext, useRef} from 'react';
|
||||
import {useEffect, useState, useContext} from 'react';
|
||||
import {AppContext} from '../context/AppContext';
|
||||
import {DisplayContext} from '../context/DisplayContext';
|
||||
import {ContextType} from '../context/ContextType';
|
||||
@ -9,14 +9,12 @@ export function useIdentity() {
|
||||
|
||||
const [state, setState] = useState({
|
||||
all: false,
|
||||
strings: display.state.strings,
|
||||
profile: {} as Profile,
|
||||
profileSet: false,
|
||||
imageUrl: null,
|
||||
strings: display.state.strings,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const updateState = (value: any) => {
|
||||
setState(s => ({...s, ...value}));
|
||||
};
|
||||
@ -38,6 +36,7 @@ export function useIdentity() {
|
||||
identity.removeProfileListener(setProfile);
|
||||
};
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const actions = {
|
||||
|
@ -11,7 +11,6 @@ export function useRoot() {
|
||||
pathname: '',
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const updateState = (value: any) => {
|
||||
setState(s => ({...s, ...value}));
|
||||
};
|
||||
@ -19,7 +18,7 @@ export function useRoot() {
|
||||
useEffect(() => {
|
||||
const {pathname} = location;
|
||||
updateState({pathname});
|
||||
}, [location.pathname]);
|
||||
}, [location]);
|
||||
|
||||
useEffect(() => {
|
||||
if (state.pathname === '/session' && !app.state.session) {
|
||||
@ -37,7 +36,7 @@ export function useRoot() {
|
||||
} else if (state.pathname !== '/session' && app.state.session) {
|
||||
navigate('/session');
|
||||
}
|
||||
}, [state.pathname, app.state.session, app.state.node]);
|
||||
}, [state.pathname, app.state.session, app.state.node, navigate]);
|
||||
|
||||
const actions = {};
|
||||
|
||||
|
@ -1,13 +1,7 @@
|
||||
import React, {useState, useContext} from 'react';
|
||||
import React, {useState} from 'react';
|
||||
import {View, useColorScheme} from 'react-native';
|
||||
import {styles} from './Session.styled';
|
||||
import {
|
||||
BottomNavigation,
|
||||
Surface,
|
||||
Menu,
|
||||
Button,
|
||||
Text,
|
||||
} from 'react-native-paper';
|
||||
import {BottomNavigation, Surface, Text} from 'react-native-paper';
|
||||
import {Settings} from '../settings/Settings';
|
||||
import {Channels} from '../channels/Channels';
|
||||
import {Contacts} from '../contacts/Contacts';
|
||||
@ -35,7 +29,7 @@ const ProfileDrawer = createDrawerNavigator();
|
||||
const DetailsDrawer = createDrawerNavigator();
|
||||
|
||||
export function Session() {
|
||||
const {state, actions} = useSession();
|
||||
const {state} = useSession();
|
||||
const scheme = useColorScheme();
|
||||
const [index, setIndex] = useState(0);
|
||||
const [routes] = useState([
|
||||
@ -88,20 +82,20 @@ export function Session() {
|
||||
|
||||
function DetailsScreen({nav}) {
|
||||
return (
|
||||
<ProfileDrawer.Navigator
|
||||
id="ProfileDrawer"
|
||||
<DetailsDrawer.Navigator
|
||||
id="DetailsDrawer"
|
||||
drawerContent={Details}
|
||||
screenOptions={{
|
||||
drawerPosition: 'right',
|
||||
drawerType: 'front',
|
||||
headerShown: false,
|
||||
}}>
|
||||
<ProfileDrawer.Screen name="profile">
|
||||
<DetailsDrawer.Screen name="details">
|
||||
{({navigation}) => (
|
||||
<ProfileScreen nav={{...nav, details: navigation}} />
|
||||
)}
|
||||
</ProfileDrawer.Screen>
|
||||
</ProfileDrawer.Navigator>
|
||||
</DetailsDrawer.Screen>
|
||||
</DetailsDrawer.Navigator>
|
||||
);
|
||||
}
|
||||
|
||||
@ -181,15 +175,15 @@ function SettingsScreen({nav}) {
|
||||
}
|
||||
|
||||
function HomeScreen({nav}) {
|
||||
const [menu, setMenu] = useState(false);
|
||||
|
||||
return (
|
||||
<View style={styles.frame}>
|
||||
<View style={styles.left}>
|
||||
<Surface elevation={2} mode="flat">
|
||||
<Identity openSettings={nav.settings.openDrawer} />
|
||||
</Surface>
|
||||
<Surface style={styles.channels} elevation={1} mode="flat"></Surface>
|
||||
<Surface style={styles.channels} elevation={1} mode="flat">
|
||||
<Text>CHANNELS</Text>
|
||||
</Surface>
|
||||
</View>
|
||||
<View style={styles.right}>
|
||||
<Text>CONVERSATION</Text>
|
||||
|
@ -1,10 +1,8 @@
|
||||
import {useEffect, useState, useContext, useRef} from 'react';
|
||||
import {useEffect, useState, useContext} from 'react';
|
||||
import {AppContext} from '../context/AppContext';
|
||||
import {DisplayContext} from '../context/DisplayContext';
|
||||
import {ContextType} from '../context/ContextType';
|
||||
|
||||
const DEBOUNCE_MS = 1000;
|
||||
|
||||
export function useSession() {
|
||||
const display = useContext(DisplayContext) as ContextType;
|
||||
const app = useContext(AppContext) as ContextType;
|
||||
@ -14,7 +12,6 @@ export function useSession() {
|
||||
strings: {},
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const updateState = (value: any) => {
|
||||
setState(s => ({...s, ...value}));
|
||||
};
|
||||
@ -22,7 +19,7 @@ export function useSession() {
|
||||
useEffect(() => {
|
||||
const {layout, strings} = display.state;
|
||||
updateState({layout, strings});
|
||||
}, [display.state.layout, display.state.strings]);
|
||||
}, [display.state]);
|
||||
|
||||
const actions = {
|
||||
logout: async () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, {useState, useContext} from 'react';
|
||||
import React, {useState} from 'react';
|
||||
import {
|
||||
Surface,
|
||||
Button,
|
||||
|
@ -38,7 +38,6 @@ export function useSettings() {
|
||||
fullDayTime: false,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const updateState = (value: any) => {
|
||||
setState(s => ({...s, ...value}));
|
||||
};
|
||||
@ -77,12 +76,13 @@ export function useSettings() {
|
||||
settings.removeConfigListener(setConfig);
|
||||
identity.removeProfileListener(setProfile);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const {fullDayTime, monthFirstDate} = app.state;
|
||||
updateState({fullDayTime, monthFirstDate});
|
||||
}, [app.state.fullDayTime, app.state.monthFirstDate]);
|
||||
}, [app.state]);
|
||||
|
||||
useEffect(() => {
|
||||
const {strings, dateFormat, timeFormat} = display.state;
|
||||
|
@ -1,6 +1,10 @@
|
||||
import {StyleSheet} from 'react-native';
|
||||
|
||||
export const styles = StyleSheet.create({
|
||||
container: {
|
||||
width: '100%',
|
||||
height: 32,
|
||||
},
|
||||
row: {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {TextInput, Text, View, TouchableOpacity} from 'react-native';
|
||||
import {TextInput, Text, View} from 'react-native';
|
||||
import React, {useState, useRef} from 'react';
|
||||
import {styles} from './InputCode.styled';
|
||||
|
||||
@ -20,7 +20,7 @@ export function InputCode({onChangeText, style}) {
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<View style={{width: '100%', height: 32}}>
|
||||
<View style={styles.container}>
|
||||
<View style={styles.row}>
|
||||
<View style={styles.cell}>
|
||||
<Text style={styles.text}>{code.charAt(0)}</Text>
|
||||
|
Loading…
x
Reference in New Issue
Block a user