mirror of
https://github.com/Qortal/qortal-mobile.git
synced 2025-03-15 04:12:32 +00:00
fix for threads
This commit is contained in:
parent
1c43396c75
commit
35652327aa
@ -493,8 +493,8 @@ export async function cancelInvitationToGroupCase(request, event) {
|
||||
|
||||
export async function leaveGroupCase(request, event) {
|
||||
try {
|
||||
const { groupId, qortalAddress } = request.payload;
|
||||
const response = await leaveGroup({ groupId, qortalAddress });
|
||||
const { groupId } = request.payload;
|
||||
const response = await leaveGroup({ groupId });
|
||||
|
||||
event.source.postMessage(
|
||||
{
|
||||
@ -611,7 +611,8 @@ export async function banFromGroupCase(request, event) {
|
||||
export async function addDataPublishesCase(request, event) {
|
||||
try {
|
||||
const { data, groupId, type } = request.payload;
|
||||
const response = await addDataPublishes({ data, groupId, type });
|
||||
const response = await addDataPublishes( data, groupId, type );
|
||||
|
||||
|
||||
event.source.postMessage(
|
||||
{
|
||||
@ -638,7 +639,8 @@ export async function addDataPublishesCase(request, event) {
|
||||
export async function getDataPublishesCase(request, event) {
|
||||
try {
|
||||
const { groupId, type } = request.payload;
|
||||
const response = await getDataPublishes({ groupId, type });
|
||||
const response = await getDataPublishes(groupId, type );
|
||||
|
||||
|
||||
event.source.postMessage(
|
||||
{
|
||||
@ -1028,6 +1030,7 @@ export async function addGroupNotificationTimestampCase(request, event) {
|
||||
const response = await addTimestampGroupAnnouncement({
|
||||
groupId,
|
||||
timestamp,
|
||||
seenTimestamp: true
|
||||
});
|
||||
|
||||
event.source.postMessage(
|
||||
@ -1546,7 +1549,7 @@ export async function publishGroupEncryptedResourceCase(request, event) {
|
||||
export async function decryptSingleForPublishesCase(request, event) {
|
||||
try {
|
||||
const { data, secretKeyObject, skipDecodeBase64} = request.payload;
|
||||
const response = await decryptSingleForPublishes({ data, secretKeyObject, skipDecodeBase64 });
|
||||
const response = await decryptSingleForPublishes({ messages: data, secretKeyObject, skipDecodeBase64 });
|
||||
|
||||
event.source.postMessage(
|
||||
{
|
||||
|
@ -95,33 +95,39 @@ 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();
|
||||
|
||||
const storedDataBase64 = await SecureStoragePlugin.get({ key });
|
||||
if (storedDataBase64.value) {
|
||||
if (keysToEncrypt.includes(key) && inMemoryKey) {
|
||||
// Decode the Base64-encoded encrypted data
|
||||
const combinedData = atob(storedDataBase64.value)
|
||||
.split("")
|
||||
.map((c) => c.charCodeAt(0));
|
||||
try {
|
||||
const storedDataBase64 = await SecureStoragePlugin.get({ key });
|
||||
|
||||
const iv = new Uint8Array(combinedData.slice(0, 12)); // First 12 bytes are the IV
|
||||
const encryptedData = new Uint8Array(combinedData.slice(12)).buffer;
|
||||
if (storedDataBase64.value) {
|
||||
if (keysToEncrypt.includes(key) && inMemoryKey) {
|
||||
// Decode the Base64-encoded encrypted data
|
||||
const combinedData = atob(storedDataBase64.value)
|
||||
.split("")
|
||||
.map((c) => c.charCodeAt(0));
|
||||
|
||||
const decryptedBase64Data = await decryptData(encryptedData, inMemoryKey, iv);
|
||||
return base64ToJson(decryptedBase64Data);
|
||||
const iv = new Uint8Array(combinedData.slice(0, 12)); // First 12 bytes are the IV
|
||||
const encryptedData = new Uint8Array(combinedData.slice(12)).buffer;
|
||||
|
||||
const decryptedBase64Data = await decryptData(encryptedData, inMemoryKey, iv);
|
||||
return base64ToJson(decryptedBase64Data);
|
||||
} else {
|
||||
// Decode non-encrypted data
|
||||
return base64ToJson(storedDataBase64.value);
|
||||
}
|
||||
} else {
|
||||
// Decode non-encrypted data
|
||||
return base64ToJson(storedDataBase64.value);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
throw new Error(`No data found for key: ${key}`);
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Remove keys from storage and log out
|
||||
export async function removeKeysAndLogout(keys: string[], event: MessageEvent, request: any) {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user