From 0940be25e89d4faf8fc4c7f57ec0c4bd1935da97 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Mon, 12 Dec 2022 14:15:45 -0800 Subject: [PATCH] present sealed option only if seal key has been set and unlocked --- net/web/src/session/channels/Channels.jsx | 8 ++++++-- net/web/src/session/channels/useChannels.hook.js | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/net/web/src/session/channels/Channels.jsx b/net/web/src/session/channels/Channels.jsx index a100ed45..96d41a6e 100644 --- a/net/web/src/session/channels/Channels.jsx +++ b/net/web/src/session/channels/Channels.jsx @@ -26,8 +26,12 @@ export function Channels({ open, active }) { const addFooter = (
- - Sealed Channel + { state.sealable && ( + <> + + Sealed Channel + + )}
diff --git a/net/web/src/session/channels/useChannels.hook.js b/net/web/src/session/channels/useChannels.hook.js index 03a1c458..2715e9f2 100644 --- a/net/web/src/session/channels/useChannels.hook.js +++ b/net/web/src/session/channels/useChannels.hook.js @@ -2,6 +2,7 @@ import { useContext, useState, useEffect } from 'react'; import { StoreContext } from 'context/StoreContext'; import { ChannelContext } from 'context/ChannelContext'; import { CardContext } from 'context/CardContext'; +import { AccountContext } from 'context/AccountContext'; import { ProfileContext } from 'context/ProfileContext'; import { ViewportContext } from 'context/ViewportContext'; @@ -17,14 +18,26 @@ export function useChannels() { members: new Set(), subject: null, seal: false, + sealable: false, }); const card = useContext(CardContext); const channel = useContext(ChannelContext); + const account = useContext(AccountContext); const store = useContext(StoreContext); const profile = useContext(ProfileContext); const viewport = useContext(ViewportContext); + useEffect(() => { + const { seal, sealKey } = account.state; + if (seal?.publicKey && sealKey?.public && sealKey?.private && seal.publicKey === sealKey.public) { + updateState({ sealable: true }); + } + else { + updateState({ sealable: false }); + } + }, [account]); + const updateState = (value) => { setState((s) => ({ ...s, ...value })); }