mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
fix for text shortcut when allowUnsealed not set
This commit is contained in:
parent
00f55bba56
commit
560263606b
@ -75,7 +75,7 @@ export function Cards({ closeCards, openContact, openChannel, openListing }) {
|
|||||||
renderItem={item => (
|
renderItem={item => (
|
||||||
<CardItem item={item} enableIce={state.enableIce} tooltip={state.tooltip} resync={() => actions.resync(item.cardId)}
|
<CardItem item={item} enableIce={state.enableIce} tooltip={state.tooltip} resync={() => actions.resync(item.cardId)}
|
||||||
open={() => openContact(item.guid)} message={() => message(item.cardId)}
|
open={() => openContact(item.guid)} message={() => message(item.cardId)}
|
||||||
call={() => call(item)} display={state.display} />
|
call={() => call(item)} display={state.display} canMessage={state.allowUnsealed || (item.seal && state.sealable)} />
|
||||||
)} />
|
)} />
|
||||||
)}
|
)}
|
||||||
{ state.cards.length === 0 && (
|
{ state.cards.length === 0 && (
|
||||||
|
@ -6,7 +6,7 @@ import { Logo } from 'logo/Logo';
|
|||||||
import { Tooltip } from 'antd';
|
import { Tooltip } from 'antd';
|
||||||
import { MessageOutlined, PhoneOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
|
import { MessageOutlined, PhoneOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
export function CardItem({ item, tooltip, enableIce, resync, open, call, message, display }) {
|
export function CardItem({ item, tooltip, enableIce, resync, open, call, message, display, canMessage }) {
|
||||||
|
|
||||||
const onResync = (e) => {
|
const onResync = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@ -45,9 +45,11 @@ export function CardItem({ item, tooltip, enableIce, resync, open, call, message
|
|||||||
)}
|
)}
|
||||||
{ item.status === 'connected' && display === 'small' && (
|
{ item.status === 'connected' && display === 'small' && (
|
||||||
<ComOptions>
|
<ComOptions>
|
||||||
<div className="option">
|
{ canMessage && (
|
||||||
<MessageOutlined onClick={onMessage} />
|
<div className="option">
|
||||||
</div>
|
<MessageOutlined onClick={onMessage} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{ enableIce && (
|
{ enableIce && (
|
||||||
<div className="option">
|
<div className="option">
|
||||||
<PhoneOutlined onClick={onCall} />
|
<PhoneOutlined onClick={onCall} />
|
||||||
@ -57,9 +59,11 @@ export function CardItem({ item, tooltip, enableIce, resync, open, call, message
|
|||||||
)}
|
)}
|
||||||
{ item.status === 'connected' && display !== 'small' && (
|
{ item.status === 'connected' && display !== 'small' && (
|
||||||
<ComOptions>
|
<ComOptions>
|
||||||
<Tooltip className="option" placement="left" title="message contact">
|
{ canMessage && (
|
||||||
<MessageOutlined onClick={onMessage} />
|
<Tooltip className="option" placement="left" title="message contact">
|
||||||
</Tooltip>
|
<MessageOutlined onClick={onMessage} />
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
{ enableIce && (
|
{ enableIce && (
|
||||||
<Tooltip className="option" placement="left" title="call contact">
|
<Tooltip className="option" placement="left" title="call contact">
|
||||||
<PhoneOutlined onClick={onCall} />
|
<PhoneOutlined onClick={onCall} />
|
||||||
|
@ -5,6 +5,7 @@ import { StoreContext } from 'context/StoreContext';
|
|||||||
import { ChannelContext } from 'context/ChannelContext';
|
import { ChannelContext } from 'context/ChannelContext';
|
||||||
import { AccountContext } from 'context/AccountContext';
|
import { AccountContext } from 'context/AccountContext';
|
||||||
import { RingContext } from 'context/RingContext';
|
import { RingContext } from 'context/RingContext';
|
||||||
|
import { encryptChannelSubject } from 'context/sealUtil';
|
||||||
|
|
||||||
export function useCards() {
|
export function useCards() {
|
||||||
|
|
||||||
@ -15,6 +16,8 @@ export function useCards() {
|
|||||||
sorted: false,
|
sorted: false,
|
||||||
display: 'small',
|
display: 'small',
|
||||||
enableIce: false,
|
enableIce: false,
|
||||||
|
sealable: false,
|
||||||
|
allowUnsealed: false,
|
||||||
cards: [],
|
cards: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -35,8 +38,14 @@ export function useCards() {
|
|||||||
}, [viewport.state]);
|
}, [viewport.state]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { enableIce } = account.state?.status || {};
|
const { seal, sealKey, status } = account.state;
|
||||||
updateState({ enableIce });
|
const allowUnsealed = account.state.status?.allowUnsealed;
|
||||||
|
if (seal?.publicKey && sealKey?.public && sealKey?.private && seal.publicKey === sealKey.public) {
|
||||||
|
updateState({ sealable: true, allowUnsealed, enableIce: status?.enableIce });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateState({ sealable: false, allowUnsealed, enableIce: status?.enableIce });
|
||||||
|
}
|
||||||
}, [account.state]);
|
}, [account.state]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -51,10 +60,11 @@ export function useCards() {
|
|||||||
const guid = profile?.guid;
|
const guid = profile?.guid;
|
||||||
const name = profile?.name;
|
const name = profile?.name;
|
||||||
const node = profile?.node;
|
const node = profile?.node;
|
||||||
|
const seal = profile?.seal;
|
||||||
const token = detail?.token;
|
const token = detail?.token;
|
||||||
const handle = profile?.node ? `${profile.handle}@${profile.node}` : profile.handle;
|
const handle = profile?.node ? `${profile.handle}@${profile.node}` : profile.handle;
|
||||||
const logo = profile?.imageSet ? card.actions.getCardImageUrl(item.id) : null;
|
const logo = profile?.imageSet ? card.actions.getCardImageUrl(item.id) : null;
|
||||||
return { cardId, guid, updated, offsync, status, name, node, token, handle, logo };
|
return { cardId, guid, updated, offsync, status, name, node, token, handle, logo, seal };
|
||||||
});
|
});
|
||||||
|
|
||||||
let latest = 0;
|
let latest = 0;
|
||||||
@ -132,15 +142,25 @@ export function useCards() {
|
|||||||
const cards = entry?.data?.channelDetail?.contacts?.cards || [];
|
const cards = entry?.data?.channelDetail?.contacts?.cards || [];
|
||||||
const subject = entry?.data?.channelDetail?.data || '';
|
const subject = entry?.data?.channelDetail?.data || '';
|
||||||
const type = entry?.data?.channelDetail?.dataType || '';
|
const type = entry?.data?.channelDetail?.dataType || '';
|
||||||
if (cards.length === 1 && cards[0] === cardId && type === 'superbasic' && subject === '{"subject":null}') {
|
|
||||||
|
if (cards.length === 1 && cards[0] === cardId && subject === '{"subject":null}') {
|
||||||
channelId = entry.id;
|
channelId = entry.id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (channelId != null) {
|
if (channelId != null) {
|
||||||
return channelId;
|
return channelId;
|
||||||
}
|
}
|
||||||
const conversation = await channel.actions.addChannel('superbasic', { subject: null }, [ cardId ]);
|
if (state.sealable && !state.allowUnsealed) {
|
||||||
return conversation.id;
|
const keys = [ account.state.sealKey.public ];
|
||||||
|
keys.push(card.state.cards.get(cardId).data.cardProfile.seal);
|
||||||
|
const sealed = encryptChannelSubject(state.subject, keys);
|
||||||
|
const conversation = await channel.actions.addChannel('sealed', sealed, [ cardId ]);
|
||||||
|
return conversation.id;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const conversation = await channel.actions.addChannel('superbasic', { subject: null }, [ cardId ]);
|
||||||
|
return conversation.id;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
call: async (contact) => {
|
call: async (contact) => {
|
||||||
const { cardId, node, guid, token } = contact;
|
const { cardId, node, guid, token } = contact;
|
||||||
|
Loading…
Reference in New Issue
Block a user