mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
present sealed option only if seal key has been set and unlocked
This commit is contained in:
parent
9ed93b07d1
commit
0940be25e8
@ -26,8 +26,12 @@ export function Channels({ open, active }) {
|
||||
const addFooter = (
|
||||
<AddFooter>
|
||||
<div class="seal">
|
||||
{ state.sealable && (
|
||||
<>
|
||||
<Switch checked={state.seal} onChange={actions.setSeal} size="small" />
|
||||
<span class="sealText">Sealed Channel</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<Button key="back" onClick={actions.clearShowAdd}>Cancel</Button>
|
||||
<Button key="save" type="primary" loading={state.busy} onClick={addChannel}>Save</Button>
|
||||
|
@ -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 }));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user