mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
more channels webapp refactor
This commit is contained in:
parent
e405f46330
commit
b348e38fd1
@ -37,10 +37,10 @@ export function encryptChannelSubject(subject, publicKeys) {
|
||||
|
||||
let seals = [];
|
||||
let crypto = new JSEncrypt();
|
||||
publicKeys.forEach(key => {
|
||||
crypto.setPublicKey(key);
|
||||
publicKeys.forEach(publicKey => {
|
||||
crypto.setPublicKey(publicKey);
|
||||
const sealedKey = crypto.encrypt(keyHex);
|
||||
seals.push({ key, sealedKey });
|
||||
seals.push({ publicKey, sealedKey });
|
||||
});
|
||||
|
||||
return { subjectEncrypted, subjectIv, seals };
|
||||
|
@ -195,7 +195,9 @@ export function useConversationContext() {
|
||||
updateState({ channel: channelSync });
|
||||
}
|
||||
else {
|
||||
syncing.current = false;
|
||||
console.log("converstaion not found");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@ import { useContext, useState, useEffect } from 'react';
|
||||
import { ChannelContext } from 'context/ChannelContext';
|
||||
import { CardContext } from 'context/CardContext';
|
||||
import { AccountContext } from 'context/AccountContext';
|
||||
import { encryptChannelSubject } from 'context/sealUtil';
|
||||
|
||||
export function useAddChannel() {
|
||||
|
||||
const [state, setState] = useState({
|
||||
sealable: false,
|
||||
busy: false,
|
||||
|
||||
showAdd: false,
|
||||
subject: null,
|
||||
members: new Set(),
|
||||
@ -45,11 +45,12 @@ export function useAddChannel() {
|
||||
cards.forEach(id => {
|
||||
keys.push(card.state.cards.get(id).data.cardProfile.seal);
|
||||
});
|
||||
|
||||
throw new Error("TODO");
|
||||
const sealed = encryptChannelSubject(state.subject, keys);
|
||||
conversation = await channel.actions.addChannel('sealed', sealed, cards);
|
||||
}
|
||||
else {
|
||||
conversation = await channel.actions.addChannel('superbasic', state.subject, cards);
|
||||
const subject = { subject: state.subject };
|
||||
conversation = await channel.actions.addChannel('superbasic', subject, cards);
|
||||
}
|
||||
updateState({ busy: false });
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ export function useChannels() {
|
||||
item.subject = null;
|
||||
}
|
||||
}
|
||||
if (item.subject == null) {
|
||||
if (item.subject == null || typeof item.subject !== 'string') {
|
||||
item.subject = item.label;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user