mirror of
https://github.com/balzack/databag.git
synced 2025-05-05 07:55:15 +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>
|
</SafeAreaView>
|
||||||
<Divider style={styles.divider} />
|
<Divider style={styles.divider} />
|
||||||
|
|
||||||
{state.profiles.length !== 0 && (
|
{state.contacts.length !== 0 && (
|
||||||
<FlatList
|
<FlatList
|
||||||
style={styles.cards}
|
style={styles.cards}
|
||||||
data={state.profiles}
|
data={state.contacts}
|
||||||
initialNumToRender={32}
|
initialNumToRender={32}
|
||||||
contentContainerStyle={state.layout === 'large' ? styles.cardsContainer : {}}
|
contentContainerStyle={state.layout === 'large' ? styles.cardsContainer : {}}
|
||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
@ -87,7 +87,7 @@ export function Registry({close, openContact}: {close?: () => void; openContact:
|
|||||||
keyExtractor={profile => profile.guid}
|
keyExtractor={profile => profile.guid}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{state.profiles.length === 0 && (
|
{state.contacts.length === 0 && (
|
||||||
<View style={styles.none}>
|
<View style={styles.none}>
|
||||||
<Text style={styles.noneLabel}>{state.strings.noContacts}</Text>
|
<Text style={styles.noneLabel}>{state.strings.noContacts}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
@ -16,6 +16,7 @@ export function useRegistry() {
|
|||||||
username: '',
|
username: '',
|
||||||
server: '',
|
server: '',
|
||||||
profiles: [] as Profile[],
|
profiles: [] as Profile[],
|
||||||
|
contacts: [] as Profile[],
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateState = (value: any) => {
|
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(() => {
|
useEffect(() => {
|
||||||
const {layout} = display.state;
|
const {layout} = display.state;
|
||||||
updateState({layout});
|
updateState({layout});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user