resetting locked state between channels

This commit is contained in:
balzack 2022-12-20 23:15:56 -08:00
parent c991a70775
commit c31ef5c703
4 changed files with 23 additions and 19 deletions

View File

@ -9,8 +9,6 @@ PODS:
- ReactCommon
- EXConstants (13.2.4):
- ExpoModulesCore
- EXErrorRecovery (3.2.0):
- ExpoModulesCore
- EXFileSystem (14.1.0):
- ExpoModulesCore
- EXFont (10.2.0):
@ -476,7 +474,6 @@ DEPENDENCIES:
- EXApplication (from `../node_modules/expo-application/ios`)
- EXAV (from `../node_modules/expo-av/ios`)
- EXConstants (from `../node_modules/expo-constants/ios`)
- EXErrorRecovery (from `../node_modules/expo-error-recovery/ios`)
- EXFileSystem (from `../node_modules/expo-file-system/ios`)
- EXFont (from `../node_modules/expo-font/ios`)
- Expo (from `../node_modules/expo`)
@ -555,8 +552,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/expo-av/ios"
EXConstants:
:path: "../node_modules/expo-constants/ios"
EXErrorRecovery:
:path: "../node_modules/expo-error-recovery/ios"
EXFileSystem:
:path: "../node_modules/expo-file-system/ios"
EXFont:
@ -664,7 +659,6 @@ SPEC CHECKSUMS:
EXApplication: e418d737a036e788510f2c4ad6c10a7d54d18586
EXAV: 596506c9bee54ad52f2f3b625cdaeb9d9f2dd6b7
EXConstants: 7c44785d41d8e959d527d23d29444277a4d1ee73
EXErrorRecovery: 74d71ee59f6814315457b09d68e86aa95cc7d05d
EXFileSystem: 927e0a8885aa9c49e50fc38eaba2c2389f2f1019
EXFont: a5d80bd9b3452b2d5abbce2487da89b0150e6487
Expo: fcdb32274e2ca9c7638d3b21b30fb665c6869219
@ -680,7 +674,7 @@ SPEC CHECKSUMS:
FirebaseInstallations: 99d24bac0243cf8b0e96cf5426340d211f0bcc80
FirebaseMessaging: 4487bbff9b9b927ba1dd3ea40d1ceb58e4ee3cb5
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 3d02b25ca00c2d456734d0bcff864cbc62f6ae1a
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431

View File

@ -400,7 +400,7 @@ export function useConversationContext() {
setView.current++;
conversationId.current = null;
reset.current = true;
updateState({ subject: null, logo: null, contacts: [], topics: new Map() });
updateState({ subject: null, logo: null, locked: true, unlocked: false, contacts: [], topics: new Map() });
}
else if (selected.cardId !== conversationId.current?.cardId || selected.channelId !== conversationId.current?.channelId) {
setView.current++;

View File

@ -161,7 +161,7 @@ export function useTopicItem(item, hosting, remove, sealed, sealKey) {
const deletable = editable || hosting;
updateState({ logo, name, nameSet, known, sealed, message, fontSize, fontColor, timestamp, transform, status, assets, deletable, editable, editData: parsed, editMessage: message });
}, [card, item]);
}, [sealKey, card, item]);
const actions = {
showCarousel: (index) => {

View File

@ -36,19 +36,29 @@ export function useConversation() {
setState((s) => ({ ...s, ...value }));
}
useEffect(() => {
let sealKey;
unlockSeal = async () => {
const { locked, seals } = conversation.state;
if (seals?.length) {
seals.forEach(seal => {
if (seal.publicKey === account.state.sealKey?.public) {
const key = '-----BEGIN RSA PRIVATE KEY-----\n' + account.state.sealKey.private + '\n-----END RSA PRIVATE KEY-----'
RSA.decrypt(seal.sealedKey, key).then(sealKey => {
updateState({ locked, sealKey });
});
try {
let sealKey;
if (seals?.length) {
for (let i = 0; i < seals.length; i++) {
const seal = seals[i];
if (seal.publicKey === account.state.sealKey?.public) {
const key = '-----BEGIN RSA PRIVATE KEY-----\n' + account.state.sealKey.private + '\n-----END RSA PRIVATE KEY-----'
const sealKey = await RSA.decrypt(seal.sealedKey, key);
return updateState({ locked, sealKey });
}
}
});
}
}
catch(err) {
console.log(err);
}
return updateState({ locked, sealKey: null });
}
useEffect(() => {
unlockSeal();
}, [conversation.state.locked, conversation.state.seals, account.state.sealKey])
useEffect(() => {