mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 07:25:15 +00:00
fixing offline login persist
This commit is contained in:
parent
e6990f0ddf
commit
6c0b0ef86a
@ -605,7 +605,10 @@
|
|||||||
"-DFOLLY_CFG_NO_COROUTINES=1",
|
"-DFOLLY_CFG_NO_COROUTINES=1",
|
||||||
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
|
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
|
||||||
);
|
);
|
||||||
OTHER_LDFLAGS = "$(inherited) ";
|
OTHER_LDFLAGS = (
|
||||||
|
"$(inherited)",
|
||||||
|
" ",
|
||||||
|
);
|
||||||
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
|
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
USE_HERMES = true;
|
USE_HERMES = true;
|
||||||
@ -677,7 +680,10 @@
|
|||||||
"-DFOLLY_CFG_NO_COROUTINES=1",
|
"-DFOLLY_CFG_NO_COROUTINES=1",
|
||||||
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
|
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
|
||||||
);
|
);
|
||||||
OTHER_LDFLAGS = "$(inherited) ";
|
OTHER_LDFLAGS = (
|
||||||
|
"$(inherited)",
|
||||||
|
" ",
|
||||||
|
);
|
||||||
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
|
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
USE_HERMES = true;
|
USE_HERMES = true;
|
||||||
|
@ -1458,7 +1458,7 @@ SPEC CHECKSUMS:
|
|||||||
RNScreens: aa943ad421c3ced3ef5a47ede02b0cbfc43a012e
|
RNScreens: aa943ad421c3ced3ef5a47ede02b0cbfc43a012e
|
||||||
RNVectorIcons: 2a2f79274248390b80684ea3c4400bd374a15c90
|
RNVectorIcons: 2a2f79274248390b80684ea3c4400bd374a15c90
|
||||||
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
|
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
|
||||||
Yoga: 88480008ccacea6301ff7bf58726e27a72931c8d
|
Yoga: 04f1db30bb810187397fa4c37dd1868a27af229c
|
||||||
|
|
||||||
PODFILE CHECKSUM: 8461018d8deceb200962c829584af7c2eb345c80
|
PODFILE CHECKSUM: 8461018d8deceb200962c829584af7c2eb345c80
|
||||||
|
|
||||||
|
@ -25,10 +25,9 @@ export class SessionStore implements SqlStore {
|
|||||||
stmt: string,
|
stmt: string,
|
||||||
params: (string | number | null)[],
|
params: (string | number | null)[],
|
||||||
): Promise<any[]> {
|
): Promise<any[]> {
|
||||||
console.log("GET: ", stmt);
|
|
||||||
const res = await this.db.executeSql(stmt, params);
|
const res = await this.db.executeSql(stmt, params);
|
||||||
const rows = [];
|
const rows = [];
|
||||||
if (res[0] && res[0].rows && res[0].rows > 1) {
|
if (res[0] && res[0].rows && res[0].rows.length > 0) {
|
||||||
for (let i = 0; i < res[0].rows.length; i++) {
|
for (let i = 0; i < res[0].rows.length; i++) {
|
||||||
rows.push(res[0].rows.item(i));
|
rows.push(res[0].rows.item(i));
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ export const styles = StyleSheet.create({
|
|||||||
maxWidth: 300,
|
maxWidth: 300,
|
||||||
width: '80%',
|
width: '80%',
|
||||||
margin: 4,
|
margin: 4,
|
||||||
marginTop: 24,
|
marginTop: 16,
|
||||||
},
|
},
|
||||||
hidden: {
|
hidden: {
|
||||||
width: '50%',
|
width: '50%',
|
||||||
|
@ -10,6 +10,7 @@ export function Access() {
|
|||||||
const [ text, setText ] = useState('');
|
const [ text, setText ] = useState('');
|
||||||
const { state, actions } = useAccess()
|
const { state, actions } = useAccess()
|
||||||
const [disabled, setDisabled] = useState(false)
|
const [disabled, setDisabled] = useState(false)
|
||||||
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
|
|
||||||
const login = async () => {
|
const login = async () => {
|
||||||
if (!state.loading) {
|
if (!state.loading) {
|
||||||
@ -101,9 +102,9 @@ export function Access() {
|
|||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
label="Password"
|
label="Password"
|
||||||
secureTextEntry
|
secureTextEntry={!showPassword}
|
||||||
left={<TextInput.Icon icon="lock" />}
|
left={<TextInput.Icon icon="lock" />}
|
||||||
right={<TextInput.Icon icon="eye" />}
|
right={showPassword ? <TextInput.Icon icon="eye-off" onPress={() => setShowPassword(false)} /> : <TextInput.Icon icon="eye" onPress={() => setShowPassword(true)} />}
|
||||||
onChangeText={value => actions.setPassword(value)}
|
onChangeText={value => actions.setPassword(value)}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
@ -111,7 +112,7 @@ export function Access() {
|
|||||||
style={styles.submit}
|
style={styles.submit}
|
||||||
onPress={login}
|
onPress={login}
|
||||||
loading={state.loading}
|
loading={state.loading}
|
||||||
disabled={!state.username || !state.password}
|
disabled={!state.username || !state.password || !state.node}
|
||||||
>
|
>
|
||||||
{state.strings.login}
|
{state.strings.login}
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -13,7 +13,7 @@ export function useAccess() {
|
|||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
wide: null,
|
wide: null,
|
||||||
strings: settings.state.strings,
|
strings: settings.state.strings,
|
||||||
mode: '',
|
mode: 'account',
|
||||||
username: '',
|
username: '',
|
||||||
handle: '',
|
handle: '',
|
||||||
password: '',
|
password: '',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect, useRef } from 'react'
|
import { useState, useEffect, useRef } from 'react'
|
||||||
import { DatabagSDK, Session } from 'databag-client-sdk'
|
import { DatabagSDK, Session } from 'databag-client-sdk'
|
||||||
import { SessionStore } from '../SessionStore'
|
import { SessionStore } from '../SessionStore'
|
||||||
const DATABAG_DB = 'db_v200.db';
|
const DATABAG_DB = 'db_v201.db';
|
||||||
|
|
||||||
export function useAppContext() {
|
export function useAppContext() {
|
||||||
const sdk = useRef(new DatabagSDK(null))
|
const sdk = useRef(new DatabagSDK(null))
|
||||||
|
@ -1,6 +1,20 @@
|
|||||||
|
import { Button } from 'react-native-paper';
|
||||||
import { Text } from 'react-native';
|
import { Text } from 'react-native';
|
||||||
|
import { AppContext } from '../context/AppContext';
|
||||||
|
import { View } from 'react-native';
|
||||||
|
import { useContext } from 'react';
|
||||||
|
|
||||||
export function Session() {
|
export function Session() {
|
||||||
return <Text>SESSION</Text>
|
const app = useContext(AppContext);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<Text>SESSION!</Text>
|
||||||
|
<Text>SESSION!</Text>
|
||||||
|
<Text>SESSION!</Text>
|
||||||
|
<Text>SESSION!</Text>
|
||||||
|
<Button mode="contained" onPress={app.actions.accountLogout}>LOGOUT</Button>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ export class OfflineStore implements Store {
|
|||||||
|
|
||||||
public async init(): Promise<Login | null> {
|
public async init(): Promise<Login | null> {
|
||||||
await this.sql.set("CREATE TABLE IF NOT EXISTS app (key text, value text, unique(key));");
|
await this.sql.set("CREATE TABLE IF NOT EXISTS app (key text, value text, unique(key));");
|
||||||
await this.sql.set("INSERT OR IGNORE INTO app (key, value) values ('session', null);");
|
await this.sql.set("INSERT OR IGNORE INTO app (key, value) values ('login', null);");
|
||||||
return await this.getAppValue('login', null);
|
return await this.getAppValue('login', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user