mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 10:05:19 +00:00
dismiss disconnected message
This commit is contained in:
parent
7a5b73d3cb
commit
cedb7ff885
@ -25,9 +25,11 @@ export class StagingFiles implements Staging {
|
||||
}
|
||||
|
||||
public async write(): Promise<{ setData: (data: string)=>Promise<void>, getUrl: ()=>Promise<string>, close: ()=>Promise<void> }> {
|
||||
let set = false;
|
||||
let extension = '';
|
||||
const path = RNFS.DocumentDirectoryPath + `/dbTmp_${Date.now()}`
|
||||
const setData = async (data: string) => {
|
||||
set = true;
|
||||
await RNFS.appendFile(path, data, 'base64');
|
||||
}
|
||||
const getUrl = async () => {
|
||||
@ -45,7 +47,13 @@ export class StagingFiles implements Staging {
|
||||
return `file://${path}${extension}`
|
||||
}
|
||||
const close = async () => {
|
||||
await RNFS.unlink(`${path}${extension}`);
|
||||
if (set) {
|
||||
try {
|
||||
await RNFS.unlink(`${path}${extension}`);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
return { setData, getUrl, close };
|
||||
}
|
||||
|
@ -204,6 +204,9 @@ export function Conversation({close}: {close: ()=>void}) {
|
||||
)}
|
||||
</View>
|
||||
<View style={styles.status}>
|
||||
{ state.detailSet && (
|
||||
<Icon source="alert-circle-outline" size={20} color={Colors.offsync} />
|
||||
)}
|
||||
{ state.detailSet && state.host && (
|
||||
<Icon source="home-outline" size={20} />
|
||||
)}
|
||||
@ -213,7 +216,6 @@ export function Conversation({close}: {close: ()=>void}) {
|
||||
{ state.detailSet && state.sealed && (
|
||||
<Icon source="shield-outline" size={18} />
|
||||
)}
|
||||
|
||||
</View>
|
||||
<IconButton style={styles.icon} mode="contained" icon="cog-outline" size={28} onPress={()=>{}} />
|
||||
</SafeAreaView>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, {useState, useCallback} from 'react';
|
||||
import {SafeAreaView, View, useColorScheme} from 'react-native';
|
||||
import {SafeAreaView, Pressable, View, useColorScheme} from 'react-native';
|
||||
import {styles} from './Session.styled';
|
||||
import {IconButton, Surface, Text, Icon} from 'react-native-paper';
|
||||
import {Settings} from '../settings/Settings';
|
||||
@ -32,6 +32,7 @@ export function Session() {
|
||||
const scheme = useColorScheme();
|
||||
const [tab, setTab] = useState('content');
|
||||
const [textCard, setTextCard] = useState({ cardId: null} as {cardId: null|string});
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
|
||||
const sessionNav = {strings: state.strings};
|
||||
const showContent = {display: tab === 'content' ? 'flex' : 'none'};
|
||||
@ -43,6 +44,13 @@ export function Session() {
|
||||
setTab('content')
|
||||
}
|
||||
|
||||
const dismiss = () => {
|
||||
setDismissed(true);
|
||||
setTimeout(() => {
|
||||
setDismissed(false);
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.session}>
|
||||
{state.layout !== 'large' && (
|
||||
@ -151,11 +159,14 @@ export function Session() {
|
||||
</View>
|
||||
</NavigationContainer>
|
||||
)}
|
||||
{ state.disconnected && (
|
||||
{ state.disconnected && !dismissed && (
|
||||
<View style={styles.alert}>
|
||||
<Surface elevation={5} style={styles.alertArea}>
|
||||
<Icon color={Colors.offsync} size={20} source="alert-circle-outline" />
|
||||
<Text style={styles.alertLabel}>{ state.strings.disconnected }</Text>
|
||||
<Pressable onPress={dismiss}>
|
||||
<Icon color={Colors.offsync} size={20} source="close" />
|
||||
</Pressable>
|
||||
</Surface>
|
||||
</View>
|
||||
)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user