dismiss disconnected message

This commit is contained in:
balzack 2025-01-06 16:16:40 -08:00
parent 7a5b73d3cb
commit cedb7ff885
3 changed files with 25 additions and 4 deletions

View File

@ -25,9 +25,11 @@ export class StagingFiles implements Staging {
} }
public async write(): Promise<{ setData: (data: string)=>Promise<void>, getUrl: ()=>Promise<string>, close: ()=>Promise<void> }> { public async write(): Promise<{ setData: (data: string)=>Promise<void>, getUrl: ()=>Promise<string>, close: ()=>Promise<void> }> {
let set = false;
let extension = ''; let extension = '';
const path = RNFS.DocumentDirectoryPath + `/dbTmp_${Date.now()}` const path = RNFS.DocumentDirectoryPath + `/dbTmp_${Date.now()}`
const setData = async (data: string) => { const setData = async (data: string) => {
set = true;
await RNFS.appendFile(path, data, 'base64'); await RNFS.appendFile(path, data, 'base64');
} }
const getUrl = async () => { const getUrl = async () => {
@ -45,7 +47,13 @@ export class StagingFiles implements Staging {
return `file://${path}${extension}` return `file://${path}${extension}`
} }
const close = async () => { 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 }; return { setData, getUrl, close };
} }

View File

@ -204,6 +204,9 @@ export function Conversation({close}: {close: ()=>void}) {
)} )}
</View> </View>
<View style={styles.status}> <View style={styles.status}>
{ state.detailSet && (
<Icon source="alert-circle-outline" size={20} color={Colors.offsync} />
)}
{ state.detailSet && state.host && ( { state.detailSet && state.host && (
<Icon source="home-outline" size={20} /> <Icon source="home-outline" size={20} />
)} )}
@ -213,7 +216,6 @@ export function Conversation({close}: {close: ()=>void}) {
{ state.detailSet && state.sealed && ( { state.detailSet && state.sealed && (
<Icon source="shield-outline" size={18} /> <Icon source="shield-outline" size={18} />
)} )}
</View> </View>
<IconButton style={styles.icon} mode="contained" icon="cog-outline" size={28} onPress={()=>{}} /> <IconButton style={styles.icon} mode="contained" icon="cog-outline" size={28} onPress={()=>{}} />
</SafeAreaView> </SafeAreaView>

View File

@ -1,5 +1,5 @@
import React, {useState, useCallback} from 'react'; 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 {styles} from './Session.styled';
import {IconButton, Surface, Text, Icon} from 'react-native-paper'; import {IconButton, Surface, Text, Icon} from 'react-native-paper';
import {Settings} from '../settings/Settings'; import {Settings} from '../settings/Settings';
@ -32,6 +32,7 @@ export function Session() {
const scheme = useColorScheme(); const scheme = useColorScheme();
const [tab, setTab] = useState('content'); const [tab, setTab] = useState('content');
const [textCard, setTextCard] = useState({ cardId: null} as {cardId: null|string}); const [textCard, setTextCard] = useState({ cardId: null} as {cardId: null|string});
const [dismissed, setDismissed] = useState(false);
const sessionNav = {strings: state.strings}; const sessionNav = {strings: state.strings};
const showContent = {display: tab === 'content' ? 'flex' : 'none'}; const showContent = {display: tab === 'content' ? 'flex' : 'none'};
@ -43,6 +44,13 @@ export function Session() {
setTab('content') setTab('content')
} }
const dismiss = () => {
setDismissed(true);
setTimeout(() => {
setDismissed(false);
}, 60000);
}
return ( return (
<View style={styles.session}> <View style={styles.session}>
{state.layout !== 'large' && ( {state.layout !== 'large' && (
@ -151,11 +159,14 @@ export function Session() {
</View> </View>
</NavigationContainer> </NavigationContainer>
)} )}
{ state.disconnected && ( { state.disconnected && !dismissed && (
<View style={styles.alert}> <View style={styles.alert}>
<Surface elevation={5} style={styles.alertArea}> <Surface elevation={5} style={styles.alertArea}>
<Icon color={Colors.offsync} size={20} source="alert-circle-outline" /> <Icon color={Colors.offsync} size={20} source="alert-circle-outline" />
<Text style={styles.alertLabel}>{ state.strings.disconnected }</Text> <Text style={styles.alertLabel}>{ state.strings.disconnected }</Text>
<Pressable onPress={dismiss}>
<Icon color={Colors.offsync} size={20} source="close" />
</Pressable>
</Surface> </Surface>
</View> </View>
)} )}