fix for threads

This commit is contained in:
PhilReact 2024-11-01 14:28:48 +02:00
parent 1c43396c75
commit 35652327aa
2 changed files with 30 additions and 21 deletions

View File

@ -493,8 +493,8 @@ export async function cancelInvitationToGroupCase(request, event) {
export async function leaveGroupCase(request, event) { export async function leaveGroupCase(request, event) {
try { try {
const { groupId, qortalAddress } = request.payload; const { groupId } = request.payload;
const response = await leaveGroup({ groupId, qortalAddress }); const response = await leaveGroup({ groupId });
event.source.postMessage( event.source.postMessage(
{ {
@ -611,7 +611,8 @@ export async function banFromGroupCase(request, event) {
export async function addDataPublishesCase(request, event) { export async function addDataPublishesCase(request, event) {
try { try {
const { data, groupId, type } = request.payload; const { data, groupId, type } = request.payload;
const response = await addDataPublishes({ data, groupId, type }); const response = await addDataPublishes( data, groupId, type );
event.source.postMessage( event.source.postMessage(
{ {
@ -638,7 +639,8 @@ export async function addDataPublishesCase(request, event) {
export async function getDataPublishesCase(request, event) { export async function getDataPublishesCase(request, event) {
try { try {
const { groupId, type } = request.payload; const { groupId, type } = request.payload;
const response = await getDataPublishes({ groupId, type }); const response = await getDataPublishes(groupId, type );
event.source.postMessage( event.source.postMessage(
{ {
@ -1028,6 +1030,7 @@ export async function addGroupNotificationTimestampCase(request, event) {
const response = await addTimestampGroupAnnouncement({ const response = await addTimestampGroupAnnouncement({
groupId, groupId,
timestamp, timestamp,
seenTimestamp: true
}); });
event.source.postMessage( event.source.postMessage(
@ -1546,7 +1549,7 @@ export async function publishGroupEncryptedResourceCase(request, event) {
export async function decryptSingleForPublishesCase(request, event) { export async function decryptSingleForPublishesCase(request, event) {
try { try {
const { data, secretKeyObject, skipDecodeBase64} = request.payload; const { data, secretKeyObject, skipDecodeBase64} = request.payload;
const response = await decryptSingleForPublishes({ data, secretKeyObject, skipDecodeBase64 }); const response = await decryptSingleForPublishes({ messages: data, secretKeyObject, skipDecodeBase64 });
event.source.postMessage( event.source.postMessage(
{ {

View File

@ -95,10 +95,12 @@ export const storeData = async (key: string, payload: any): Promise<string> => {
}; };
export const getData = async <T = any>(key: string): Promise<T> => { export const getData = async <T = any>(key: string): Promise<T | null> => {
await initializeKeyAndIV(); await initializeKeyAndIV();
try {
const storedDataBase64 = await SecureStoragePlugin.get({ key }); const storedDataBase64 = await SecureStoragePlugin.get({ key });
if (storedDataBase64.value) { if (storedDataBase64.value) {
if (keysToEncrypt.includes(key) && inMemoryKey) { if (keysToEncrypt.includes(key) && inMemoryKey) {
// Decode the Base64-encoded encrypted data // Decode the Base64-encoded encrypted data
@ -116,12 +118,16 @@ export const getData = async <T = any>(key: string): Promise<T> => {
return base64ToJson(storedDataBase64.value); return base64ToJson(storedDataBase64.value);
} }
} else { } else {
throw new Error(`No data found for key: ${key}`); return null;
}
} catch (error) {
return null
} }
}; };
// Remove keys from storage and log out // Remove keys from storage and log out
export async function removeKeysAndLogout(keys: string[], event: MessageEvent, request: any) { export async function removeKeysAndLogout(keys: string[], event: MessageEvent, request: any) {
try { try {