From b3f04d35b25def2bb8b1cc8b06d94a5596ee20c8 Mon Sep 17 00:00:00 2001 From: balzack Date: Tue, 5 Nov 2024 13:17:28 -0800 Subject: [PATCH] formatting code --- app/client/mobile/src/channel/Channel.tsx | 6 +---- app/client/mobile/src/contacts/Contacts.tsx | 12 ++++----- app/client/mobile/src/content/Content.tsx | 3 +-- .../mobile/src/content/useContent.hook.ts | 25 +++++++++++++------ .../mobile/src/conversation/Conversation.tsx | 1 + app/client/mobile/src/session/Session.tsx | 8 +++--- 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/app/client/mobile/src/channel/Channel.tsx b/app/client/mobile/src/channel/Channel.tsx index e543c2dd..26376913 100644 --- a/app/client/mobile/src/channel/Channel.tsx +++ b/app/client/mobile/src/channel/Channel.tsx @@ -1,12 +1,10 @@ -import React, {ReactNode} from 'react'; +import React from 'react'; import {SafeAreaView, Image, View, Pressable} from 'react-native'; import {Text} from 'react-native-paper'; import {styles} from './Channel.styled'; export function Channel({ containerStyle, - sealed, - hosted, unread, imageUrl, notesPlaceholder, @@ -17,8 +15,6 @@ export function Channel({ select, }: { containerStyle: any; - sealed: boolean; - hosted: boolean; unread: boolean; imageUrl: string; notesPlaceholder: string; diff --git a/app/client/mobile/src/contacts/Contacts.tsx b/app/client/mobile/src/contacts/Contacts.tsx index f19bfc23..c8d427df 100644 --- a/app/client/mobile/src/contacts/Contacts.tsx +++ b/app/client/mobile/src/contacts/Contacts.tsx @@ -64,9 +64,9 @@ export function Contacts({openRegistry, openContact}: {openRegistry: () => void; contentContainerStyle={styles.cardsContainer} showsVerticalScrollIndicator={false} renderItem={({item}) => { - const status = item.offsync ? 'offsync' : item.status; + const syncStatus = item.offsync ? 'offsync' : item.status; const getOptions = () => { - if (status === 'connected') { + if (syncStatus === 'connected') { return [ void; }} />, ]; - } else if (status === 'offsync') { + } else if (syncStatus === 'offsync') { return [ void; }} />, ]; - } else if (status === 'received') { + } else if (syncStatus === 'received') { return [ void; }} />, ]; - } else if (status === 'connecting') { + } else if (syncStatus === 'connecting') { return [ void; }} />, ]; - } else if (status === 'pending') { + } else if (syncStatus === 'pending') { return [ { const channels = state.sorted.map(channel => { - const {cardId, channelId, unread, sealed, members, data, dataType, lastTopic} = channel; + const {cardId, channelId, unread, sealed, members, data, lastTopic} = channel; const contacts = []; if (cardId) { const card = state.cards.find(contact => contact.cardId === cardId); @@ -75,19 +75,19 @@ export function useContent() { }; const selectImage = () => { - if (contacts.length == 0) { + if (contacts.length === 0) { return notes; - } else if (contacts.length == 1) { + } else if (contacts.length === 1) { if (contacts[0]) { return contacts[0].imageUrl; } else { return unknown; } - } else if (contacts.length == 2) { + } else if (contacts.length === 2) { return iii_group; - } else if (contacts.length == 3) { + } else if (contacts.length === 3) { return iiii_group; - } else if (contacts.length == 4) { + } else if (contacts.length === 4) { return iiiii_group; } else { return group; @@ -99,7 +99,16 @@ export function useContent() { const message = lastTopic ? (lastTopic.data ? lastTopic.data.text : null) : ''; const imageUrl = selectImage(); - return {cardId, channelId, sealed, hosted, unread, imageUrl, subject, message}; + return { + cardId, + channelId, + sealed, + hosted, + unread, + imageUrl, + subject, + message, + }; }); const search = state.filter?.toLowerCase(); @@ -136,7 +145,7 @@ export function useContent() { const sorted = merged.sort((a, b) => { const aUpdated = a?.lastTopic?.created; const bUpdated = b?.lastTopic?.created; - if (aUpdated == bUpdated) { + if (aUpdated === bUpdated) { return 0; } else if (!aUpdated) { return 1; diff --git a/app/client/mobile/src/conversation/Conversation.tsx b/app/client/mobile/src/conversation/Conversation.tsx index fd7a122e..e7245ca7 100644 --- a/app/client/mobile/src/conversation/Conversation.tsx +++ b/app/client/mobile/src/conversation/Conversation.tsx @@ -1,3 +1,4 @@ +import React from 'react'; import {Text} from 'react-native-paper'; export function Conversation() { diff --git a/app/client/mobile/src/session/Session.tsx b/app/client/mobile/src/session/Session.tsx index 7a1e9e72..6028d12f 100644 --- a/app/client/mobile/src/session/Session.tsx +++ b/app/client/mobile/src/session/Session.tsx @@ -157,15 +157,15 @@ function ContentTab({scheme}: {scheme: string}) { {props => ( { - setFocus(focus); + select={channel => { + setFocus(channel); props.navigation.navigate('conversation'); }} /> )} - {() => } + {() => } @@ -357,7 +357,7 @@ function HomeScreen({nav}) { - setFocus(focus)} /> + setFocus(channel)} />