Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to make chat more reliable #391

Merged
merged 9 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,12 @@ const App = () => {
}, []);

const fetchServerStatusState = useCallback(async () => {
const response = await fetch(STATUS_URL, {cache: 'no-cache'});
if (!response.ok) {
let response: Response | null = null
try {
response = await fetch(STATUS_URL, {cache: 'no-cache'});
} catch (e) {};

if (response === null || !response.ok) {
// If even the status server is down, things are *very* not-okay. But odds
// are it can't be contacted because the user has a crappy internet
// connection. The "You're offline" notice should still provide some
Expand Down
63 changes: 47 additions & 16 deletions components/inbox-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { TopNavBarButton } from './top-nav-bar-button';
import { inboxOrder, inboxSection } from '../kv-storage/inbox';
import { signedInUser } from '../App';
import { Notice } from './notice';
import { listen } from '../events/events';
import { listen, lastEvent } from '../events/events';

const Stack = createNativeStackNavigator();

Expand Down Expand Up @@ -311,21 +311,10 @@ const InboxTab_ = ({navigation}) => {

return (
<SafeAreaView style={styles.safeAreaView}>
<TopNavBar>
<DefaultText
style={{
fontWeight: '700',
fontSize: 20,
}}
>
{'Inbox' + (showArchive ? ' (Archive)' : '')}
</DefaultText>
<TopNavBarButton
onPress={onPressArchiveButton}
iconName={showArchive ? 'chatbubbles-outline' : 'file-tray-full-outline'}
style={{right: 15}}
/>
</TopNavBar>
<InboxTabNavBar
showArchive={showArchive}
onPressArchiveButton={onPressArchiveButton}
/>
{inbox === null &&
<View style={{height: '100%', justifyContent: 'center', alignItems: 'center'}}>
<ActivityIndicator size="large" color="#70f" />
Expand All @@ -349,6 +338,48 @@ const InboxTab_ = ({navigation}) => {
);
};

const InboxTabNavBar = ({
showArchive,
onPressArchiveButton,
}) => {
const [isOnline, setIsOnline] = useState(lastEvent('xmpp-is-online') ?? false);

useEffect(() => {
return listen('xmpp-is-online', setIsOnline);
}, []);

return (
<TopNavBar>
<View>
<DefaultText
style={{
fontWeight: '700',
fontSize: 20,
}}
>
{'Inbox' + (showArchive ? ' (Archive)' : '')}
</DefaultText>
{!isOnline &&
<ActivityIndicator
size="small"
color="#70f"
style={{
position: 'absolute',
right: -40,
top: 3,
}}
/>
}
</View>
<TopNavBarButton
onPress={onPressArchiveButton}
iconName={showArchive ? 'chatbubbles-outline' : 'file-tray-full-outline'}
style={{right: 15}}
/>
</TopNavBar>
);
};

const styles = StyleSheet.create({
safeAreaView: {
flex: 1
Expand Down
5 changes: 5 additions & 0 deletions components/stream-error-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Platform,
Text,
View,
} from 'react-native';
Expand All @@ -18,6 +19,10 @@ const StreamErrorModal = () => {
return <></>;
};

if (Platform.OS !== 'web') {
return <></>;
}

return (
<View
style={{
Expand Down
Loading
Loading