formatting code

This commit is contained in:
balzack 2024-11-05 13:17:28 -08:00
parent cccce4ebd7
commit b3f04d35b2
6 changed files with 30 additions and 25 deletions

View File

@ -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;

View File

@ -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 [
<Action
key="call"
@ -85,7 +85,7 @@ export function Contacts({openRegistry, openContact}: {openRegistry: () => void;
}}
/>,
];
} else if (status === 'offsync') {
} else if (syncStatus === 'offsync') {
return [
<Action
key="resync"
@ -101,7 +101,7 @@ export function Contacts({openRegistry, openContact}: {openRegistry: () => void;
}}
/>,
];
} else if (status === 'received') {
} else if (syncStatus === 'received') {
return [
<Action
key="accept"
@ -117,7 +117,7 @@ export function Contacts({openRegistry, openContact}: {openRegistry: () => void;
}}
/>,
];
} else if (status === 'connecting') {
} else if (syncStatus === 'connecting') {
return [
<Action
key="cancel"
@ -133,7 +133,7 @@ export function Contacts({openRegistry, openContact}: {openRegistry: () => void;
}}
/>,
];
} else if (status === 'pending') {
} else if (syncStatus === 'pending') {
return [
<Action
key="accept"

View File

@ -1,8 +1,7 @@
import React from 'react';
import {Divider, Surface, IconButton, Button, Text, TextInput, useTheme} from 'react-native-paper';
import {Divider, Surface, Button, Text, TextInput, useTheme} from 'react-native-paper';
import {SafeAreaView, FlatList, View} from 'react-native';
import {styles} from './Content.styled';
import {Colors} from '../constants/Colors';
import {useContent} from './useContent.hook';
import {Channel} from '../channel/Channel';
import {Focus} from 'databag-client-sdk';

View File

@ -41,7 +41,7 @@ export function useContent() {
useEffect(() => {
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;

View File

@ -1,3 +1,4 @@
import React from 'react';
import {Text} from 'react-native-paper';
export function Conversation() {

View File

@ -157,15 +157,15 @@ function ContentTab({scheme}: {scheme: string}) {
<ContentStack.Screen name="content" options={{headerBackTitleVisible: false}}>
{props => (
<Content
select={(focus: Focus) => {
setFocus(focus);
select={channel => {
setFocus(channel);
props.navigation.navigate('conversation');
}}
/>
)}
</ContentStack.Screen>
<ContentStack.Screen name="conversation" options={{headerBackTitleVisible: false}}>
{() => <Conversation />}
{() => <Conversation focus={focus} />}
</ContentStack.Screen>
</ContentStack.Navigator>
</NavigationContainer>
@ -357,7 +357,7 @@ function HomeScreen({nav}) {
<Identity openSettings={nav.settings.openDrawer} openContacts={nav.contacts.openDrawer} />
</Surface>
<Surface style={styles.channels} elevation={1} mode="flat">
<Content select={(focus: Focus) => setFocus(focus)} />
<Content select={channel => setFocus(channel)} />
</Surface>
</View>
<View style={styles.right}>