restrict searching until federated name set

This commit is contained in:
Roland Osborne 2024-05-03 22:38:41 -07:00
parent b3ad138fa3
commit 948009558c
5 changed files with 22 additions and 7 deletions

View File

@ -138,6 +138,7 @@ function ContactStackScreen({ addChannel }) {
const [contact, setContact] = useState(null); const [contact, setContact] = useState(null);
const [editable, setEditable] = useState(false);
const [search, setSearch] = useState(null); const [search, setSearch] = useState(null);
const [handle, setHandle] = useState(); const [handle, setHandle] = useState();
const [server, setServer] = useState(); const [server, setServer] = useState();
@ -147,6 +148,12 @@ function ContactStackScreen({ addChannel }) {
navigation.navigate('contact') navigation.navigate('contact')
} }
const openRegistry = (navigation) => { const openRegistry = (navigation) => {
if (profile.state.identity?.node) {
setEditable(true);
}
else {
setEditable(false);
}
setServer(profile.state.server); setServer(profile.state.server);
setHandle(null); setHandle(null);
setSearch(false); setSearch(false);
@ -166,7 +173,7 @@ function ContactStackScreen({ addChannel }) {
</ContactStack.Screen> </ContactStack.Screen>
<ContactStack.Screen name="registry" options={{ ...stackParams, cardStyle: {backgroundColor: Colors.screenBase}, headerTitle: (props) => ( <ContactStack.Screen name="registry" options={{ ...stackParams, cardStyle: {backgroundColor: Colors.screenBase}, headerTitle: (props) => (
<RegistryHeader search={search} setSearch={setSearch} handle={handle} setHandle={setHandle} server={server} setServer={setServer} /> <RegistryHeader search={search} editable={editable} setSearch={setSearch} handle={handle} setHandle={setHandle} server={server} setServer={setServer} />
)}}> )}}>
{(props) => <RegistryBody search={search} handle={handle} server={server} openContact={(contact) => openContact(props.navigation, contact)} />} {(props) => <RegistryBody search={search} handle={handle} server={server} openContact={(contact) => openContact(props.navigation, contact)} />}
</ContactStack.Screen> </ContactStack.Screen>

View File

@ -45,7 +45,7 @@ export function useCards() {
cardId: cardId, cardId: cardId,
name: name, name: name,
handle: handle, handle: handle,
username: `${handle}/${node}`, username: node ? `${handle}/${node}` : handle,
node: node, node: node,
guid: guid, guid: guid,
location: location, location: location,

View File

@ -25,7 +25,8 @@ export function useAddMember(item, members) {
useEffect(() => { useEffect(() => {
const { cardId, revision, profile } = item; const { cardId, revision, profile } = item;
const { name, handle, node } = profile; const { name, handle, node } = profile;
updateState({ cardId, name, handle: `${handle}/${node}`, const username = node ? `${handle}/${node}` : handle;
updateState({ cardId, name, handle: username,
logo: profile.imageSet ? card.actions.getCardImageUrl(cardId) : 'avatar' }); logo: profile.imageSet ? card.actions.getCardImageUrl(cardId) : 'avatar' });
}, [card.state]); }, [card.state]);

View File

@ -7,12 +7,12 @@ import { ProfileContext } from 'context/ProfileContext';
import Colors from 'constants/Colors'; import Colors from 'constants/Colors';
import Ionicons from 'react-native-vector-icons/AntDesign'; import Ionicons from 'react-native-vector-icons/AntDesign';
export function RegistryHeader({ search, setSearch, handle, setHandle, server, setServer }) { export function RegistryHeader({ search, setSearch, handle, setHandle, server, setServer, editable }) {
return ( return (
<View style={styles.title}> <View style={styles.title}>
<View style={styles.inputwrapper}> <View style={styles.inputwrapper}>
<TextInput style={styles.inputfield} value={server} onChangeText={setServer} <TextInput style={styles.inputfield} value={server} onChangeText={setServer} editable={editable}
autoCorrect={false} autoCapitalize="none" placeholderTextColor={Colors.disabled} placeholder="Server" /> autoCorrect={false} autoCapitalize="none" placeholderTextColor={Colors.disabled} placeholder="Server" />
</View> </View>
{ !search && ( { !search && (
@ -60,9 +60,16 @@ export function Registry({ closeRegistry, openContact }) {
const [search, setSearch] = useState(false); const [search, setSearch] = useState(false);
const [handle, setHandle] = useState(); const [handle, setHandle] = useState();
const [server, setServer] = useState(); const [server, setServer] = useState();
const [editable, setEditable] = useState(false);
const profile = useContext(ProfileContext); const profile = useContext(ProfileContext);
useEffect(() => { useEffect(() => {
if (profile.state.identity?.node) {
setEditable(true);
}
else {
setEditable(false);
}
setSearch(false); setSearch(false);
setHandle(null); setHandle(null);
setServer(profile.state.server); setServer(profile.state.server);
@ -71,7 +78,7 @@ export function Registry({ closeRegistry, openContact }) {
return ( return (
<View> <View>
<View style={styles.header}> <View style={styles.header}>
<RegistryHeader search={search} setSearch={setSearch} handle={handle} setHandle={setHandle} server={server} setServer={setServer} /> <RegistryHeader search={search} editable={editable} setSearch={setSearch} handle={handle} setHandle={setHandle} server={server} setServer={setServer} />
</View> </View>
<RegistryBody search={search} handle={handle} server={server} openContact={openContact} /> <RegistryBody search={search} handle={handle} server={server} openContact={openContact} />
</View> </View>

View File

@ -47,7 +47,7 @@ export function useRegistry(search, handle, server) {
const { guid, name, handle, node, location, description, imageSet } = item; const { guid, name, handle, node, location, description, imageSet } = item;
const server = node ? node : profile.state.server; const server = node ? node : profile.state.server;
const logo = imageSet ? getListingImageUrl(server, guid) : 'avatar'; const logo = imageSet ? getListingImageUrl(server, guid) : 'avatar';
const username = `${handle}/${node}`; const username = node ? `${handle}/${node}` : handle;
return { guid, name, handle, username, node: server, location, description, guid, imageSet, logo }; return { guid, name, handle, username, node: server, location, description, guid, imageSet, logo };
}; };