merge from main

This commit is contained in:
Roland Osborne 2023-10-06 14:48:26 -07:00
commit a3a99eb3ba
5 changed files with 33 additions and 8 deletions

View File

@ -31,10 +31,10 @@ export function useLogin() {
}, [app.state.session]);
useEffect(() => {
if (state.password && state.login && !state.enabled && state.login.includes('@')) {
if (state.password && state.login && !state.enabled && (state.login.includes('@') || state.login.includes('/'))) {
updateState({ enabled: true });
}
if ((!state.password || !state.login || !state.login.includes('@')) && state.enabled) {
if ((!state.password || !state.login || (!state.login.includes('@') && !state.login.includes('/'))) && state.enabled) {
updateState({ enabled: false });
}
}, [state.login, state.password]);

View File

@ -120,7 +120,7 @@ export function useAppContext() {
throw new Error('invalid session state');
}
updateState({ loggedOut: false });
const acc = username.split('@');
const acc = username.includes('/') ? username.split('/') : username.split('@');
const session = await setLogin(acc[0], acc[1], password, getApplicationName(), getVersion(), getDeviceId(), deviceToken.current, notifications)
access.current = { loginTimestamp: session.created, server: acc[1], token: session.appToken, guid: session.guid };
await store.actions.setSession(access.current);

View File

@ -57,6 +57,29 @@ export function Cards({ navigation, openContact, openRegistry, addChannel }) {
return (
<View style={styles.container}>
<View style={styles.title}>
{ state.sort && (
<TouchableOpacity style={styles.sort} onPress={() => actions.setSort(false)}>
<MatIcons style={styles.icon} name="sort-ascending" size={24} color={Colors.text} />
</TouchableOpacity>
)}
{ !state.sort && (
<TouchableOpacity style={styles.sort} onPress={() => actions.setSort(true)}>
<MatIcons style={styles.icon} name="sort-ascending" size={24} color={Colors.unsetText} />
</TouchableOpacity>
)}
<View style={styles.inputwrapper}>
<AntIcons style={styles.icon} name="search1" size={16} color={Colors.inputPlaceholder} />
<TextInput placeholder={ state.strings.contactFilter } placeholderTextColor={Colors.inputPlaceholder} value={state.filter}
style={styles.inputfield} autoCapitalize={'none'} spellCheck={false} onChangeText={actions.setFilter} />
<View style={styles.space} />
</View>
<TouchableOpacity style={styles.add} onPress={() => openRegistry(navigation)}>
<AntIcons name={'adduser'} size={16} color={Colors.primaryButtonText} style={[styles.box, { transform: [ { rotateY: "180deg" }, ]} ]}/>
<Text style={styles.newtext}>{ state.strings.add }</Text>
</TouchableOpacity>
</View>
{ state.cards.length == 0 && (
<View style={styles.notfound}>
<Text style={styles.notfoundtext}>{ state.strings.noContacts }</Text>

View File

@ -5,7 +5,7 @@ import { AccountContext } from 'context/AccountContext';
import { ProfileContext } from 'context/ProfileContext';
import { getLanguageStrings } from 'constants/Strings';
export function useCards(filter, sort) {
export function useCards() {
const [state, setState] = useState({
cards: [],
@ -58,10 +58,10 @@ export function useCards(filter, sort) {
if (item.blocked) {
return false;
}
if (!filter) {
if (!state.filter) {
return true;
}
const lower = filter.toLowerCase();
const lower = state.filter.toLowerCase();
if (item.name) {
if (item.name.toLowerCase().includes(lower)) {
return true;
@ -74,7 +74,7 @@ export function useCards(filter, sort) {
}
return false;
})
if (sort) {
if (state.sort) {
filtered.sort((a, b) => {
const aName = a?.name?.toLowerCase();
const bName = b?.name?.toLowerCase();
@ -99,7 +99,7 @@ export function useCards(filter, sort) {
});
}
updateState({ cards: filtered });
}, [card, filter, sort]);
}, [card, state.filter, state.sort]);
const actions = {
call: async (card) => {

View File

@ -369,6 +369,7 @@ export const styles = StyleSheet.create({
height: 32,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
cancelButtonText: {
color: Colors.cancelButtonText,
@ -386,6 +387,7 @@ export const styles = StyleSheet.create({
height: 32,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
saveButtonText: {
color: Colors.primaryButtonText,