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.addControls}>
|
||||||
<View style={styles.sealed}>
|
<View style={styles.sealed}>
|
||||||
|
{ state.sealable && (
|
||||||
|
<>
|
||||||
<Switch style={styles.switch} trackColor={styles.track}
|
<Switch style={styles.switch} trackColor={styles.track}
|
||||||
value={state.sealed} onValueChange={actions.setSealed} />
|
value={state.sealed} onValueChange={actions.setSealed} />
|
||||||
<Text style={styles.sealedText}>Sealed</Text>
|
<Text style={styles.sealedText}>Sealed</Text>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
<TouchableOpacity style={styles.cancel} onPress={actions.hideAdding}>
|
<TouchableOpacity style={styles.cancel} onPress={actions.hideAdding}>
|
||||||
<Text>Cancel</Text>
|
<Text>Cancel</Text>
|
||||||
@ -184,9 +188,13 @@ export function Channels({ openConversation }) {
|
|||||||
)}
|
)}
|
||||||
<View style={styles.addControls}>
|
<View style={styles.addControls}>
|
||||||
<View style={styles.sealed}>
|
<View style={styles.sealed}>
|
||||||
|
{ state.sealable && (
|
||||||
|
<>
|
||||||
<Switch style={styles.switch} trackColor={styles.track}
|
<Switch style={styles.switch} trackColor={styles.track}
|
||||||
value={state.sealed} onValueChange={actions.setSealed} />
|
value={state.sealed} onValueChange={actions.setSealed} />
|
||||||
<Text>Sealed</Text>
|
<Text>Sealed</Text>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
<TouchableOpacity style={styles.cancel} onPress={actions.hideAdding}>
|
<TouchableOpacity style={styles.cancel} onPress={actions.hideAdding}>
|
||||||
<Text>Cancel</Text>
|
<Text>Cancel</Text>
|
||||||
|
@ -3,6 +3,7 @@ import { useWindowDimensions } from 'react-native';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { CardContext } from 'context/CardContext';
|
import { CardContext } from 'context/CardContext';
|
||||||
import { ChannelContext } from 'context/ChannelContext';
|
import { ChannelContext } from 'context/ChannelContext';
|
||||||
|
import { AccountContext } from 'context/AccountContext';
|
||||||
import { ProfileContext } from 'context/ProfileContext';
|
import { ProfileContext } from 'context/ProfileContext';
|
||||||
import { AppContext } from 'context/AppContext';
|
import { AppContext } from 'context/AppContext';
|
||||||
import config from 'constants/Config';
|
import config from 'constants/Config';
|
||||||
@ -19,9 +20,11 @@ export function useChannels() {
|
|||||||
addSubject: null,
|
addSubject: null,
|
||||||
addMembers: [],
|
addMembers: [],
|
||||||
sealed: false,
|
sealed: false,
|
||||||
|
sealable: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const items = useRef([]);
|
const items = useRef([]);
|
||||||
|
const account = useContext(AccountContext);
|
||||||
const channel = useContext(ChannelContext);
|
const channel = useContext(ChannelContext);
|
||||||
const card = useContext(CardContext);
|
const card = useContext(CardContext);
|
||||||
const profile = useContext(ProfileContext);
|
const profile = useContext(ProfileContext);
|
||||||
@ -32,6 +35,16 @@ export function useChannels() {
|
|||||||
setState((s) => ({ ...s, ...value }));
|
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(() => {
|
useEffect(() => {
|
||||||
const contacts = Array.from(card.state.cards.values());
|
const contacts = Array.from(card.state.cards.values());
|
||||||
const filtered = contacts.filter(contact => {
|
const filtered = contacts.filter(contact => {
|
||||||
|
Loading…
Reference in New Issue
Block a user