mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-20 10:05:56 +00:00
fix group embed decryption
This commit is contained in:
parent
b422e274e8
commit
916d1302a4
@ -124,3 +124,8 @@ export const blobKeySelector = selectorFamily({
|
||||
return blobs[key] || null; // Return the value for the key or null if not found
|
||||
},
|
||||
});
|
||||
|
||||
export const selectedGroupIdAtom = atom({
|
||||
key: 'selectedGroupIdAtom',
|
||||
default: null,
|
||||
});
|
@ -40,6 +40,7 @@ export const AttachmentCard = ({
|
||||
isLoadingParent,
|
||||
errorMsg,
|
||||
encryptionType,
|
||||
selectedGroupId
|
||||
}) => {
|
||||
|
||||
const [isOpen, setIsOpen] = useState(true);
|
||||
@ -86,7 +87,7 @@ export const AttachmentCard = ({
|
||||
|
||||
{
|
||||
data64: data,
|
||||
groupId: 683,
|
||||
groupId: selectedGroupId,
|
||||
}
|
||||
|
||||
);
|
||||
|
@ -8,8 +8,8 @@ import { extractComponents } from "../Chat/MessageDisplay";
|
||||
import { executeEvent } from "../../utils/events";
|
||||
|
||||
import { base64ToBlobUrl } from "../../utils/fileReading";
|
||||
import { useRecoilValue, useSetRecoilState } from "recoil";
|
||||
import { blobControllerAtom, blobKeySelector, resourceKeySelector } from "../../atoms/global";
|
||||
import { useRecoilState, useRecoilValue, useSetRecoilState } from "recoil";
|
||||
import { blobControllerAtom, blobKeySelector, resourceKeySelector, selectedGroupIdAtom } from "../../atoms/global";
|
||||
import { parseQortalLink } from "./embed-utils";
|
||||
import { PollCard } from "./PollEmbed";
|
||||
import { ImageCard } from "./ImageEmbed";
|
||||
@ -59,7 +59,7 @@ export const Embed = ({ embedLink }) => {
|
||||
const [imageUrl, setImageUrl] = useState("");
|
||||
const [parsedData, setParsedData] = useState(null);
|
||||
const setBlobs = useSetRecoilState(blobControllerAtom);
|
||||
|
||||
const [selectedGroupId] = useRecoilState(selectedGroupIdAtom)
|
||||
const resourceData = useMemo(()=> {
|
||||
const parsedDataOnTheFly = parseQortalLink(embedLink);
|
||||
if(parsedDataOnTheFly?.service && parsedDataOnTheFly?.name && parsedDataOnTheFly?.identifier){
|
||||
@ -148,22 +148,24 @@ export const Embed = ({ embedLink }) => {
|
||||
);
|
||||
}
|
||||
if(encryptionType === 'group'){
|
||||
|
||||
decryptedData = await window.sendMessage(
|
||||
"DECRYPT_QORTAL_GROUP_DATA",
|
||||
|
||||
{
|
||||
data64: data,
|
||||
groupId: 683,
|
||||
groupId: selectedGroupId,
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error('Unable to decrypt')
|
||||
}
|
||||
|
||||
if (!decryptedData || decryptedData?.error) throw new Error("Could not decrypt data");
|
||||
imageFinalUrl = base64ToBlobUrl(decryptedData)
|
||||
imageFinalUrl = base64ToBlobUrl(decryptedData, parsedData?.mimeType ? decodeURIComponent(parsedData?.mimeType) : undefined)
|
||||
setBlobs((prev=> {
|
||||
return {
|
||||
...prev,
|
||||
@ -357,6 +359,7 @@ export const Embed = ({ embedLink }) => {
|
||||
isLoadingParent={isLoading}
|
||||
errorMsg={errorMsg}
|
||||
encryptionType={encryptionType}
|
||||
selectedGroupId={selectedGroupId}
|
||||
/>
|
||||
)}
|
||||
<CustomizedSnackbars
|
||||
|
@ -97,6 +97,8 @@ import { HubsIcon } from "../../assets/Icons/HubsIcon";
|
||||
import { MessagingIcon } from "../../assets/Icons/MessagingIcon";
|
||||
import { formatEmailDate } from "./QMailMessages";
|
||||
import { AdminSpace } from "../Chat/AdminSpace";
|
||||
import { useSetRecoilState } from "recoil";
|
||||
import { selectedGroupIdAtom } from "../../atoms/global";
|
||||
|
||||
// let touchStartY = 0;
|
||||
// let disablePullToRefresh = false;
|
||||
@ -476,7 +478,7 @@ export const Group = ({
|
||||
const [appsModeDev, setAppsModeDev] = useState('home')
|
||||
const [isOpenSideViewDirects, setIsOpenSideViewDirects] = useState(false)
|
||||
const [isOpenSideViewGroups, setIsOpenSideViewGroups] = useState(false)
|
||||
|
||||
const setSelectedGroupId = useSetRecoilState(selectedGroupIdAtom)
|
||||
const toggleSideViewDirects = ()=> {
|
||||
if(isOpenSideViewGroups){
|
||||
setIsOpenSideViewGroups(false)
|
||||
@ -502,6 +504,7 @@ export const Group = ({
|
||||
|
||||
useEffect(() => {
|
||||
selectedGroupRef.current = selectedGroup;
|
||||
setSelectedGroupId(selectedGroup?.groupId)
|
||||
}, [selectedGroup]);
|
||||
|
||||
useEffect(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user