mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 23:45:21 +00:00
fixing account reset flow
This commit is contained in:
parent
34e382ae72
commit
8f8c2f30ae
@ -72,12 +72,14 @@ export function useAppContext() {
|
|||||||
},
|
},
|
||||||
access: async (server, token) => {
|
access: async (server, token) => {
|
||||||
const access = await setAccountAccess(server, token);
|
const access = await setAccountAccess(server, token);
|
||||||
|
console.log("ACCESS", access);
|
||||||
await store.actions.setSession({ ...access, server});
|
await store.actions.setSession({ ...access, server});
|
||||||
await setSession({ ...access, server });
|
await setSession({ ...access, server });
|
||||||
},
|
},
|
||||||
login: async (username, password) => {
|
login: async (username, password) => {
|
||||||
const acc = username.split('@');
|
const acc = username.split('@');
|
||||||
const access = await setLogin(acc[0], acc[1], password)
|
const access = await setLogin(acc[0], acc[1], password)
|
||||||
|
console.log("ACCESS2", access);
|
||||||
await store.actions.setSession({ ...access, server: acc[1]});
|
await store.actions.setSession({ ...access, server: acc[1]});
|
||||||
await setSession({ ...access, server: acc[1] });
|
await setSession({ ...access, server: acc[1] });
|
||||||
},
|
},
|
||||||
@ -111,7 +113,6 @@ export function useAppContext() {
|
|||||||
}
|
}
|
||||||
ws.current.onclose = (e) => {
|
ws.current.onclose = (e) => {
|
||||||
count.current += 1;
|
count.current += 1;
|
||||||
console.log("CURRENT1: ", count.current);
|
|
||||||
updateState({ disconnected: count.current });
|
updateState({ disconnected: count.current });
|
||||||
console.log(e)
|
console.log(e)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -129,7 +130,6 @@ console.log("CURRENT1: ", count.current);
|
|||||||
}
|
}
|
||||||
ws.current.error = (e) => {
|
ws.current.error = (e) => {
|
||||||
count.current += 1;
|
count.current += 1;
|
||||||
console.log("CURRENT2: ", count.current);
|
|
||||||
updateState({ disconnected: count.current });
|
updateState({ disconnected: count.current });
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useState, useRef, useContext } from 'react';
|
import { useEffect, useState, useRef, useContext } from 'react';
|
||||||
import SQLite from "react-native-sqlite-storage";
|
import SQLite from "react-native-sqlite-storage";
|
||||||
|
|
||||||
const DATABAG_DB = 'databag_v042.db';
|
const DATABAG_DB = 'databag_v044.db';
|
||||||
|
|
||||||
export function useStoreContext() {
|
export function useStoreContext() {
|
||||||
const [state, setState] = useState({});
|
const [state, setState] = useState({});
|
||||||
|
@ -14,6 +14,9 @@ export function Dashboard(props) {
|
|||||||
const { config, server, token } = location.state;
|
const { config, server, token } = location.state;
|
||||||
const { state, actions } = useDashboard(config, server, token);
|
const { state, actions } = useDashboard(config, server, token);
|
||||||
|
|
||||||
|
console.log(state.createToken);
|
||||||
|
console.log(state.accessToken);
|
||||||
|
|
||||||
const saveConfig = async () => {
|
const saveConfig = async () => {
|
||||||
try {
|
try {
|
||||||
await actions.saveConfig();
|
await actions.saveConfig();
|
||||||
@ -256,7 +259,7 @@ export function Dashboard(props) {
|
|||||||
</View>
|
</View>
|
||||||
<View style={styles.accessToken}>
|
<View style={styles.accessToken}>
|
||||||
<Text style={styles.tokenLabel}>Token:</Text>
|
<Text style={styles.tokenLabel}>Token:</Text>
|
||||||
<TouchableOpacity style={styles.copy}>
|
<TouchableOpacity style={styles.copy} onPress={() => Clipboard.setString(state.accessToken)}>
|
||||||
<Text style={styles.token}>{ state.accessToken }</Text>
|
<Text style={styles.token}>{ state.accessToken }</Text>
|
||||||
<AntIcon style={styles.icon} name={'copy1'} size={20} />
|
<AntIcon style={styles.icon} name={'copy1'} size={20} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { View, StatusBar, TouchableOpacity, Text } from 'react-native';
|
import { View, TouchableOpacity, StatusBar, Text } from 'react-native';
|
||||||
import { useState, useEffect, useContext } from 'react';
|
import { useState, useEffect, useContext } from 'react';
|
||||||
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
|
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
|
||||||
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { useState, useEffect, useContext } from 'react';
|
import { useState, useEffect, useContext } from 'react';
|
||||||
import { CardContext } from 'context/CardContext';
|
import { CardContext } from 'context/CardContext';
|
||||||
|
import { AppContext } from 'context/AppContext';
|
||||||
|
|
||||||
export function useCardsIcon(active) {
|
export function useCardsIcon(active) {
|
||||||
|
|
||||||
@ -8,6 +9,7 @@ export function useCardsIcon(active) {
|
|||||||
setRevision: null,
|
setRevision: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const app = useContext(AppContext);
|
||||||
const card = useContext(CardContext);
|
const card = useContext(CardContext);
|
||||||
|
|
||||||
const updateState = (value) => {
|
const updateState = (value) => {
|
||||||
@ -23,9 +25,11 @@ export function useCardsIcon(active) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let revision;
|
let revision;
|
||||||
card.state.cards.forEach((contact) => {
|
card.state.cards.forEach((contact) => {
|
||||||
if (contact?.detail?.status === 'pending' || contact?.detail?.status === 'requested') {
|
if (contact?.detail?.statusUpdated > app.state.loginTimestamp) {
|
||||||
if (!revision || contact.detailRevision > revision) {
|
if (contact?.detail?.status === 'pending' || contact?.detail?.status === 'requested') {
|
||||||
revision = contact.detailRevision;
|
if (!revision || contact.detailRevision > revision) {
|
||||||
|
revision = contact.detailRevision;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -33,7 +37,6 @@ export function useCardsIcon(active) {
|
|||||||
card.actions.setRequestRevision(state.curRevision);
|
card.actions.setRequestRevision(state.curRevision);
|
||||||
}
|
}
|
||||||
updateState({ setRevision: card.state.requestRevision, curRevision: revision });
|
updateState({ setRevision: card.state.requestRevision, curRevision: revision });
|
||||||
|
|
||||||
}, [card]);
|
}, [card]);
|
||||||
|
|
||||||
const actions = {};
|
const actions = {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user