mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 01:55:17 +00:00
removing self from registry on search
This commit is contained in:
parent
04747b12c8
commit
feb66f1502
@ -47,10 +47,10 @@ export function Registry({close, openContact}: {close?: () => void; openContact:
|
||||
</SafeAreaView>
|
||||
<Divider style={styles.divider} />
|
||||
|
||||
{state.profiles.length !== 0 && (
|
||||
{state.contacts.length !== 0 && (
|
||||
<FlatList
|
||||
style={styles.cards}
|
||||
data={state.profiles}
|
||||
data={state.contacts}
|
||||
initialNumToRender={32}
|
||||
contentContainerStyle={state.layout === 'large' ? styles.cardsContainer : {}}
|
||||
showsVerticalScrollIndicator={false}
|
||||
@ -87,7 +87,7 @@ export function Registry({close, openContact}: {close?: () => void; openContact:
|
||||
keyExtractor={profile => profile.guid}
|
||||
/>
|
||||
)}
|
||||
{state.profiles.length === 0 && (
|
||||
{state.contacts.length === 0 && (
|
||||
<View style={styles.none}>
|
||||
<Text style={styles.noneLabel}>{state.strings.noContacts}</Text>
|
||||
</View>
|
||||
|
@ -16,6 +16,7 @@ export function useRegistry() {
|
||||
username: '',
|
||||
server: '',
|
||||
profiles: [] as Profile[],
|
||||
contacts: [] as Profile[],
|
||||
});
|
||||
|
||||
const updateState = (value: any) => {
|
||||
@ -44,6 +45,25 @@ export function useRegistry() {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
updateState({ contacts: state.profiles.filter((profile: Profile) => profile.guid !== state.guid) });
|
||||
}, [state.profiles, state.guid]);
|
||||
|
||||
useEffect(() => {
|
||||
const identity = app.state?.session?.getIdentity();
|
||||
const setProfile = (profile: Profile) => {
|
||||
const {guid} = profile;
|
||||
updateState({ guid });
|
||||
};
|
||||
if (identity) {
|
||||
identity.addProfileListener(setProfile);
|
||||
return () => {
|
||||
identity.removeProfileListener(setProfile);
|
||||
};
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const {layout} = display.state;
|
||||
updateState({layout});
|
||||
|
Loading…
x
Reference in New Issue
Block a user