more channels webapp refactor

This commit is contained in:
Roland Osborne 2023-01-18 21:28:00 -08:00
parent e405f46330
commit b348e38fd1
4 changed files with 11 additions and 8 deletions

View File

@ -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 };

View File

@ -195,7 +195,9 @@ export function useConversationContext() {
updateState({ channel: channelSync });
}
else {
syncing.current = false;
console.log("converstaion not found");
return;
}
}

View File

@ -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 });
}

View File

@ -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;
}