removing self from registry on search

This commit is contained in:
Roland Osborne 2025-02-07 15:41:23 -08:00
parent 04747b12c8
commit feb66f1502
2 changed files with 23 additions and 3 deletions

View File

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

View File

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