From 89b7e2b95075f9bfc8b75f8a10b67183abbee45b Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Mon, 12 Dec 2022 14:31:54 -0800 Subject: [PATCH] render seal option only if sealkey set --- app/mobile/src/session/channels/Channels.jsx | 20 +++++++++++++------ .../src/session/channels/useChannels.hook.js | 13 ++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/app/mobile/src/session/channels/Channels.jsx b/app/mobile/src/session/channels/Channels.jsx index 98130d7f..51a1a4bb 100644 --- a/app/mobile/src/session/channels/Channels.jsx +++ b/app/mobile/src/session/channels/Channels.jsx @@ -87,9 +87,13 @@ export function ChannelsBody({ state, actions, openConversation }) { )} - - Sealed + { state.sealable && ( + <> + + Sealed + + )} Cancel @@ -184,9 +188,13 @@ export function Channels({ openConversation }) { )} - - Sealed + { state.sealable && ( + <> + + Sealed + + )} Cancel diff --git a/app/mobile/src/session/channels/useChannels.hook.js b/app/mobile/src/session/channels/useChannels.hook.js index a9256d05..5e6833d3 100644 --- a/app/mobile/src/session/channels/useChannels.hook.js +++ b/app/mobile/src/session/channels/useChannels.hook.js @@ -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 => {