mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
render seal option only if sealkey set
This commit is contained in:
parent
0940be25e8
commit
89b7e2b950
@ -87,9 +87,13 @@ export function ChannelsBody({ state, actions, openConversation }) {
|
||||
)}
|
||||
<View style={styles.addControls}>
|
||||
<View style={styles.sealed}>
|
||||
<Switch style={styles.switch} trackColor={styles.track}
|
||||
value={state.sealed} onValueChange={actions.setSealed} />
|
||||
<Text style={styles.sealedText}>Sealed</Text>
|
||||
{ state.sealable && (
|
||||
<>
|
||||
<Switch style={styles.switch} trackColor={styles.track}
|
||||
value={state.sealed} onValueChange={actions.setSealed} />
|
||||
<Text style={styles.sealedText}>Sealed</Text>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
<TouchableOpacity style={styles.cancel} onPress={actions.hideAdding}>
|
||||
<Text>Cancel</Text>
|
||||
@ -184,9 +188,13 @@ export function Channels({ openConversation }) {
|
||||
)}
|
||||
<View style={styles.addControls}>
|
||||
<View style={styles.sealed}>
|
||||
<Switch style={styles.switch} trackColor={styles.track}
|
||||
value={state.sealed} onValueChange={actions.setSealed} />
|
||||
<Text>Sealed</Text>
|
||||
{ state.sealable && (
|
||||
<>
|
||||
<Switch style={styles.switch} trackColor={styles.track}
|
||||
value={state.sealed} onValueChange={actions.setSealed} />
|
||||
<Text>Sealed</Text>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
<TouchableOpacity style={styles.cancel} onPress={actions.hideAdding}>
|
||||
<Text>Cancel</Text>
|
||||
|
@ -3,6 +3,7 @@ import { useWindowDimensions } from 'react-native';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { CardContext } from 'context/CardContext';
|
||||
import { ChannelContext } from 'context/ChannelContext';
|
||||
import { AccountContext } from 'context/AccountContext';
|
||||
import { ProfileContext } from 'context/ProfileContext';
|
||||
import { AppContext } from 'context/AppContext';
|
||||
import config from 'constants/Config';
|
||||
@ -19,9 +20,11 @@ export function useChannels() {
|
||||
addSubject: null,
|
||||
addMembers: [],
|
||||
sealed: false,
|
||||
sealable: false,
|
||||
});
|
||||
|
||||
const items = useRef([]);
|
||||
const account = useContext(AccountContext);
|
||||
const channel = useContext(ChannelContext);
|
||||
const card = useContext(CardContext);
|
||||
const profile = useContext(ProfileContext);
|
||||
@ -32,6 +35,16 @@ export function useChannels() {
|
||||
setState((s) => ({ ...s, ...value }));
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const { status, sealKey } = account.state;
|
||||
if (status?.seal?.publicKey && sealKey?.public && sealKey?.private && sealKey?.public === status.seal.publicKey) {
|
||||
updateState({ sealable: true });
|
||||
}
|
||||
else {
|
||||
updateState({ sealed: false, sealable: false });
|
||||
}
|
||||
}, [account]);
|
||||
|
||||
useEffect(() => {
|
||||
const contacts = Array.from(card.state.cards.values());
|
||||
const filtered = contacts.filter(contact => {
|
||||
|
Loading…
Reference in New Issue
Block a user