mirror of
https://github.com/Qortal/qortal-mobile.git
synced 2025-03-31 01:35:54 +00:00
fixes
This commit is contained in:
parent
20e5b00697
commit
4de4f58498
@ -173,6 +173,44 @@ export function openIndexedDB() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const listOfAllQortalRequests = [
|
||||||
|
'GET_USER_ACCOUNT', 'DECRYPT_DATA', 'SEND_COIN', 'GET_LIST_ITEMS',
|
||||||
|
'ADD_LIST_ITEMS', 'DELETE_LIST_ITEM', 'VOTE_ON_POLL', 'CREATE_POLL',
|
||||||
|
'SEND_CHAT_MESSAGE', 'JOIN_GROUP', 'DEPLOY_AT', 'GET_USER_WALLET',
|
||||||
|
'GET_WALLET_BALANCE', 'GET_USER_WALLET_INFO', 'GET_CROSSCHAIN_SERVER_INFO',
|
||||||
|
'GET_TX_ACTIVITY_SUMMARY', 'GET_FOREIGN_FEE', 'UPDATE_FOREIGN_FEE',
|
||||||
|
'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER',
|
||||||
|
'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY', 'CREATE_TRADE_BUY_ORDER', 'CREATE_TRADE_SELL_ORDER', 'CANCEL_TRADE_SELL_ORDER', 'IS_USING_GATEWAY', 'ADMIN_ACTION', 'SIGN_TRANSACTION', 'OPEN_NEW_TAB', 'CREATE_AND_COPY_EMBED_LINK', 'DECRYPT_QORTAL_GROUP_DATA', 'DECRYPT_DATA_WITH_SHARING_KEY', 'DELETE_HOSTED_DATA', 'GET_HOSTED_DATA', 'PUBLISH_MULTIPLE_QDN_RESOURCES',
|
||||||
|
'PUBLISH_QDN_RESOURCE',
|
||||||
|
'ENCRYPT_DATA',
|
||||||
|
'ENCRYPT_DATA_WITH_SHARING_KEY',
|
||||||
|
'ENCRYPT_QORTAL_GROUP_DATA',
|
||||||
|
'SAVE_FILE',
|
||||||
|
'GET_ACCOUNT_DATA',
|
||||||
|
'GET_ACCOUNT_NAMES',
|
||||||
|
'SEARCH_NAMES',
|
||||||
|
'GET_NAME_DATA',
|
||||||
|
'GET_QDN_RESOURCE_URL',
|
||||||
|
'LINK_TO_QDN_RESOURCE',
|
||||||
|
'LIST_QDN_RESOURCES',
|
||||||
|
'SEARCH_QDN_RESOURCES',
|
||||||
|
'FETCH_QDN_RESOURCE',
|
||||||
|
'GET_QDN_RESOURCE_STATUS',
|
||||||
|
'GET_QDN_RESOURCE_PROPERTIES',
|
||||||
|
'GET_QDN_RESOURCE_METADATA',
|
||||||
|
'SEARCH_CHAT_MESSAGES',
|
||||||
|
'LIST_GROUPS',
|
||||||
|
'GET_BALANCE',
|
||||||
|
'GET_AT',
|
||||||
|
'GET_AT_DATA',
|
||||||
|
'LIST_ATS',
|
||||||
|
'FETCH_BLOCK',
|
||||||
|
'FETCH_BLOCK_RANGE',
|
||||||
|
'SEARCH_TRANSACTIONS',
|
||||||
|
'GET_PRICE',
|
||||||
|
'SHOW_ACTIONS'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const UIQortalRequests = [
|
const UIQortalRequests = [
|
||||||
@ -183,7 +221,7 @@ const UIQortalRequests = [
|
|||||||
'GET_TX_ACTIVITY_SUMMARY', 'GET_FOREIGN_FEE', 'UPDATE_FOREIGN_FEE',
|
'GET_TX_ACTIVITY_SUMMARY', 'GET_FOREIGN_FEE', 'UPDATE_FOREIGN_FEE',
|
||||||
'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER',
|
'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER',
|
||||||
'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY', 'CREATE_TRADE_BUY_ORDER',
|
'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY', 'CREATE_TRADE_BUY_ORDER',
|
||||||
'CREATE_TRADE_SELL_ORDER', 'CANCEL_TRADE_SELL_ORDER', 'IS_USING_GATEWAY', 'SIGN_TRANSACTION', 'ADMIN_ACTION', 'OPEN_NEW_TAB', 'CREATE_AND_COPY_EMBED_LINK', 'DECRYPT_QORTAL_GROUP_DATA', 'DECRYPT_DATA_WITH_SHARING_KEY', 'DELETE_HOSTED_DATA', 'GET_HOSTED_DATA'
|
'CREATE_TRADE_SELL_ORDER', 'CANCEL_TRADE_SELL_ORDER', 'IS_USING_GATEWAY', 'SIGN_TRANSACTION', 'ADMIN_ACTION', 'OPEN_NEW_TAB', 'CREATE_AND_COPY_EMBED_LINK', 'DECRYPT_QORTAL_GROUP_DATA', 'DECRYPT_DATA_WITH_SHARING_KEY', 'DELETE_HOSTED_DATA', 'GET_HOSTED_DATA', 'SHOW_ACTIONS'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ export const getGroupMembers = async (groupNumber: number) => {
|
|||||||
return groupData;
|
return groupData;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const decryptResource = async (data: string) => {
|
export const decryptResource = async (data: string, fromQortalRequest?:boolean) => {
|
||||||
try {
|
try {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
window.sendMessage("decryptGroupEncryption", {
|
window.sendMessage("decryptGroupEncryption", {
|
||||||
@ -261,10 +261,19 @@ export const decryptResource = async (data: string) => {
|
|||||||
res(response);
|
res(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rej(response.error);
|
if(fromQortalRequest){
|
||||||
|
rej({error: response.error, message: response?.error});
|
||||||
|
} else {
|
||||||
|
rej(response.error);
|
||||||
|
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
rej(error.message || "An error occurred");
|
if(fromQortalRequest){
|
||||||
|
rej({message: error.message || "An error occurred", error: error.message || "An error occurred"});
|
||||||
|
} else {
|
||||||
|
rej(error.message || "An error occurred",);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -24,15 +24,12 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import {
|
|
||||||
AutoSizer,
|
|
||||||
CellMeasurer,
|
|
||||||
CellMeasurerCache,
|
|
||||||
List,
|
|
||||||
} from "react-virtualized";
|
|
||||||
import { getNameInfo } from "./Group";
|
import { getNameInfo } from "./Group";
|
||||||
import { getBaseApi, getFee } from "../../background";
|
import { getBaseApi, getFee } from "../../background";
|
||||||
import { LoadingButton } from "@mui/lab";
|
import { LoadingButton } from "@mui/lab";
|
||||||
|
import LockIcon from '@mui/icons-material/Lock';
|
||||||
|
import NoEncryptionGmailerrorredIcon from '@mui/icons-material/NoEncryptionGmailerrorred';
|
||||||
import {
|
import {
|
||||||
MyContext,
|
MyContext,
|
||||||
getArbitraryEndpointReact,
|
getArbitraryEndpointReact,
|
||||||
@ -49,8 +46,9 @@ import ShortUniqueId from "short-unique-id";
|
|||||||
import { CustomizedSnackbars } from "../Snackbar/Snackbar";
|
import { CustomizedSnackbars } from "../Snackbar/Snackbar";
|
||||||
import { getGroupNames } from "./UserListOfInvites";
|
import { getGroupNames } from "./UserListOfInvites";
|
||||||
import { WrapperUserAction } from "../WrapperUserAction";
|
import { WrapperUserAction } from "../WrapperUserAction";
|
||||||
import LockIcon from '@mui/icons-material/Lock';
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||||
import NoEncryptionGmailerrorredIcon from '@mui/icons-material/NoEncryptionGmailerrorred';
|
import ErrorBoundary from "../../common/ErrorBoundary";
|
||||||
|
|
||||||
export const requestQueuePromos = new RequestQueueWithPromise(20);
|
export const requestQueuePromos = new RequestQueueWithPromise(20);
|
||||||
|
|
||||||
export function utf8ToBase64(inputString: string): string {
|
export function utf8ToBase64(inputString: string): string {
|
||||||
@ -67,10 +65,7 @@ export function utf8ToBase64(inputString: string): string {
|
|||||||
|
|
||||||
const uid = new ShortUniqueId({ length: 8 });
|
const uid = new ShortUniqueId({ length: 8 });
|
||||||
|
|
||||||
const cache = new CellMeasurerCache({
|
|
||||||
fixedWidth: true,
|
|
||||||
defaultHeight: 50,
|
|
||||||
});
|
|
||||||
|
|
||||||
export function getGroupId(str) {
|
export function getGroupId(str) {
|
||||||
const match = str.match(/group-(\d+)-/);
|
const match = str.match(/group-(\d+)-/);
|
||||||
@ -101,6 +96,18 @@ export const ListOfGroupPromotions = () => {
|
|||||||
const { show, setTxList } = useContext(MyContext);
|
const { show, setTxList } = useContext(MyContext);
|
||||||
|
|
||||||
const listRef = useRef();
|
const listRef = useRef();
|
||||||
|
const rowVirtualizer = useVirtualizer({
|
||||||
|
count: promotions.length,
|
||||||
|
getItemKey: React.useCallback(
|
||||||
|
(index) => promotions[index]?.identifier,
|
||||||
|
[promotions]
|
||||||
|
),
|
||||||
|
getScrollElement: () => listRef.current,
|
||||||
|
estimateSize: () => 80, // Provide an estimated height of items, adjust this as needed
|
||||||
|
overscan: 10, // Number of items to render outside the visible area to improve smoothness
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
@ -189,7 +196,7 @@ export const ListOfGroupPromotions = () => {
|
|||||||
}, initialDelay);
|
}, initialDelay);
|
||||||
|
|
||||||
return () => clearTimeout(initialTimeout);
|
return () => clearTimeout(initialTimeout);
|
||||||
}, [getPromotions]);
|
}, [getPromotions, promotionTimeInterval]);
|
||||||
|
|
||||||
const handlePopoverOpen = (event, index) => {
|
const handlePopoverOpen = (event, index) => {
|
||||||
setPopoverAnchor(event.currentTarget);
|
setPopoverAnchor(event.currentTarget);
|
||||||
@ -323,286 +330,6 @@ export const ListOfGroupPromotions = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// const handleCancelInvitation = async (address)=> {
|
|
||||||
// try {
|
|
||||||
// const fee = await getFee('CANCEL_GROUP_INVITE')
|
|
||||||
// await show({
|
|
||||||
// message: "Would you like to perform a CANCEL_GROUP_INVITE transaction?" ,
|
|
||||||
// publishFee: fee.fee + ' QORT'
|
|
||||||
// })
|
|
||||||
// setIsLoadingCancelInvite(true)
|
|
||||||
// await new Promise((res, rej)=> {
|
|
||||||
// window.sendMessage("cancelInvitationToGroup", {
|
|
||||||
// groupId,
|
|
||||||
// qortalAddress: address,
|
|
||||||
// })
|
|
||||||
// .then((response) => {
|
|
||||||
// if (!response?.error) {
|
|
||||||
// setInfoSnack({
|
|
||||||
// type: "success",
|
|
||||||
// message: "Successfully canceled invitation. It may take a couple of minutes for the changes to propagate",
|
|
||||||
// });
|
|
||||||
// setOpenSnack(true);
|
|
||||||
// handlePopoverClose();
|
|
||||||
// setIsLoadingCancelInvite(true);
|
|
||||||
// res(response);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// setInfoSnack({
|
|
||||||
// type: "error",
|
|
||||||
// message: response?.error,
|
|
||||||
// });
|
|
||||||
// setOpenSnack(true);
|
|
||||||
// rej(response.error);
|
|
||||||
// })
|
|
||||||
// .catch((error) => {
|
|
||||||
// setInfoSnack({
|
|
||||||
// type: "error",
|
|
||||||
// message: error.message || "An error occurred",
|
|
||||||
// });
|
|
||||||
// setOpenSnack(true);
|
|
||||||
// rej(error);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// })
|
|
||||||
// } catch (error) {
|
|
||||||
|
|
||||||
// } finally {
|
|
||||||
// setIsLoadingCancelInvite(false)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
const rowRenderer = ({ index, key, parent, style }) => {
|
|
||||||
const promotion = promotions[index];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<CellMeasurer
|
|
||||||
key={key}
|
|
||||||
cache={cache}
|
|
||||||
parent={parent}
|
|
||||||
columnIndex={0}
|
|
||||||
rowIndex={index}
|
|
||||||
>
|
|
||||||
{({ measure }) => (
|
|
||||||
<div style={style} onLoad={measure}>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
width: "100%",
|
|
||||||
padding: "0px 20px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Popover
|
|
||||||
open={openPopoverIndex === promotion?.groupId}
|
|
||||||
anchorEl={popoverAnchor}
|
|
||||||
onClose={(event, reason) => {
|
|
||||||
if (reason === "backdropClick") {
|
|
||||||
// Prevent closing on backdrop click
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handlePopoverClose(); // Close only on other events like Esc key press
|
|
||||||
}}
|
|
||||||
anchorOrigin={{
|
|
||||||
vertical: "top",
|
|
||||||
horizontal: "center",
|
|
||||||
}}
|
|
||||||
transformOrigin={{
|
|
||||||
vertical: "bottom",
|
|
||||||
horizontal: "center",
|
|
||||||
}}
|
|
||||||
style={{ marginTop: "8px" }}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
width: "325px",
|
|
||||||
height: "auto",
|
|
||||||
maxHeight: "400px",
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: "10px",
|
|
||||||
padding: "10px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
fontSize: "13px",
|
|
||||||
fontWeight: 600,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Group name: {` ${promotion?.groupName}`}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
fontSize: "13px",
|
|
||||||
fontWeight: 600,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Number of members: {` ${promotion?.memberCount}`}
|
|
||||||
</Typography>
|
|
||||||
{promotion?.description && (
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
fontSize: "13px",
|
|
||||||
fontWeight: 600,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{promotion?.description}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
{promotion?.isOpen === false && (
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
fontSize: "13px",
|
|
||||||
fontWeight: 600,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
*This is a closed/private group, so you will need to wait
|
|
||||||
until an admin accepts your request
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
<Spacer height="5px" />
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
gap: "20px",
|
|
||||||
alignItems: "center",
|
|
||||||
width: "100%",
|
|
||||||
justifyContent: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<LoadingButton
|
|
||||||
loading={isLoadingJoinGroup}
|
|
||||||
loadingPosition="start"
|
|
||||||
variant="contained"
|
|
||||||
onClick={handlePopoverClose}
|
|
||||||
>
|
|
||||||
Close
|
|
||||||
</LoadingButton>
|
|
||||||
<LoadingButton
|
|
||||||
loading={isLoadingJoinGroup}
|
|
||||||
loadingPosition="start"
|
|
||||||
variant="contained"
|
|
||||||
onClick={() =>
|
|
||||||
handleJoinGroup(promotion, promotion?.isOpen)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Join
|
|
||||||
</LoadingButton>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Popover>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: "15px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Avatar
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "#27282c",
|
|
||||||
color: "white",
|
|
||||||
}}
|
|
||||||
alt={promotion?.name}
|
|
||||||
src={`${getBaseApiReact()}/arbitrary/THUMBNAIL/${
|
|
||||||
promotion?.name
|
|
||||||
}/qortal_avatar?async=true`}
|
|
||||||
>
|
|
||||||
{promotion?.name?.charAt(0)}
|
|
||||||
</Avatar>
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
fontWight: 600,
|
|
||||||
fontFamily: "Inter",
|
|
||||||
color: "cadetBlue",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{promotion?.name}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
</Box>
|
|
||||||
<Spacer height="20px"/>
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
fontWight: 600,
|
|
||||||
fontFamily: "Inter",
|
|
||||||
color: "cadetBlue",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{promotion?.groupName}
|
|
||||||
</Typography>
|
|
||||||
<Spacer height="20px" />
|
|
||||||
<Box sx={{
|
|
||||||
display: 'flex',
|
|
||||||
gap: '20px',
|
|
||||||
alignItems: 'center'
|
|
||||||
}}>
|
|
||||||
{promotion?.isOpen === false && (
|
|
||||||
<LockIcon sx={{
|
|
||||||
color: 'var(--green)'
|
|
||||||
}} />
|
|
||||||
)}
|
|
||||||
{promotion?.isOpen === true && (
|
|
||||||
<NoEncryptionGmailerrorredIcon sx={{
|
|
||||||
color: 'var(--danger)'
|
|
||||||
}} />
|
|
||||||
)}
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
fontSize: "15px",
|
|
||||||
fontWeight: 600,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{promotion?.isOpen ? 'Public group' : 'Private group' }
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Spacer height="20px" />
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
fontWight: 600,
|
|
||||||
fontFamily: "Inter",
|
|
||||||
color: "cadetBlue",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{promotion?.data}
|
|
||||||
</Typography>
|
|
||||||
<Spacer height="20px" />
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
justifyContent: "center",
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
onClick={(event) => handlePopoverOpen(event, promotion?.groupId)}
|
|
||||||
sx={{
|
|
||||||
fontSize: "12px",
|
|
||||||
color: 'white'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Join Group: {` ${promotion?.groupName}`}
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Spacer height="50px" />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</CellMeasurer>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -697,25 +424,293 @@ export const ListOfGroupPromotions = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
height: "600px",
|
height: "600px",
|
||||||
}}
|
position: "relative",
|
||||||
>
|
display: "flex",
|
||||||
<AutoSizer>
|
flexDirection: "column",
|
||||||
{({ height, width }) => (
|
width: "100%",
|
||||||
<List
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
ref={listRef}
|
ref={listRef}
|
||||||
width={width}
|
className="scrollable-container"
|
||||||
height={height}
|
style={{
|
||||||
rowCount={promotions.length}
|
flexGrow: 1,
|
||||||
rowHeight={cache.rowHeight}
|
overflow: "auto",
|
||||||
rowRenderer={rowRenderer}
|
position: "relative",
|
||||||
deferredMeasurementCache={cache}
|
display: "flex",
|
||||||
/>
|
height: "0px",
|
||||||
)}
|
}}
|
||||||
</AutoSizer>
|
>
|
||||||
</div>
|
<div
|
||||||
|
style={{
|
||||||
|
height: rowVirtualizer.getTotalSize(),
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
||||||
|
const index = virtualRow.index;
|
||||||
|
const promotion = promotions[index];
|
||||||
|
return (
|
||||||
|
|
||||||
|
<div
|
||||||
|
data-index={virtualRow.index} //needed for dynamic row height measurement
|
||||||
|
ref={rowVirtualizer.measureElement} //measure dynamic row height
|
||||||
|
key={promotion?.identifier}
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: 0,
|
||||||
|
left: "50%", // Move to the center horizontally
|
||||||
|
transform: `translateY(${virtualRow.start}px) translateX(-50%)`, // Adjust for centering
|
||||||
|
width: "100%", // Control width (90% of the parent)
|
||||||
|
padding: "10px 0",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
overscrollBehavior: "none",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ErrorBoundary
|
||||||
|
fallback={
|
||||||
|
<Typography>
|
||||||
|
Error loading content: Invalid Data
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
width: "100%",
|
||||||
|
padding: "0px 20px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Popover
|
||||||
|
open={openPopoverIndex === promotion?.groupId}
|
||||||
|
anchorEl={popoverAnchor}
|
||||||
|
onClose={(event, reason) => {
|
||||||
|
if (reason === "backdropClick") {
|
||||||
|
// Prevent closing on backdrop click
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
handlePopoverClose(); // Close only on other events like Esc key press
|
||||||
|
}}
|
||||||
|
anchorOrigin={{
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
}}
|
||||||
|
transformOrigin={{
|
||||||
|
vertical: "bottom",
|
||||||
|
horizontal: "center",
|
||||||
|
}}
|
||||||
|
style={{ marginTop: "8px" }}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: "325px",
|
||||||
|
height: "auto",
|
||||||
|
maxHeight: "400px",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "10px",
|
||||||
|
padding: "10px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontSize: "13px",
|
||||||
|
fontWeight: 600,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Group name: {` ${promotion?.groupName}`}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontSize: "13px",
|
||||||
|
fontWeight: 600,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Number of members: {` ${promotion?.memberCount}`}
|
||||||
|
</Typography>
|
||||||
|
{promotion?.description && (
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontSize: "13px",
|
||||||
|
fontWeight: 600,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{promotion?.description}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
{promotion?.isOpen === false && (
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontSize: "13px",
|
||||||
|
fontWeight: 600,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
*This is a closed/private group, so you will need to wait
|
||||||
|
until an admin accepts your request
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
<Spacer height="5px" />
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
gap: "20px",
|
||||||
|
alignItems: "center",
|
||||||
|
width: "100%",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LoadingButton
|
||||||
|
loading={isLoadingJoinGroup}
|
||||||
|
loadingPosition="start"
|
||||||
|
variant="contained"
|
||||||
|
onClick={handlePopoverClose}
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</LoadingButton>
|
||||||
|
<LoadingButton
|
||||||
|
loading={isLoadingJoinGroup}
|
||||||
|
loadingPosition="start"
|
||||||
|
variant="contained"
|
||||||
|
onClick={() =>
|
||||||
|
handleJoinGroup(promotion, promotion?.isOpen)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Join
|
||||||
|
</LoadingButton>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Popover>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "15px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Avatar
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "#27282c",
|
||||||
|
color: "white",
|
||||||
|
}}
|
||||||
|
alt={promotion?.name}
|
||||||
|
src={`${getBaseApiReact()}/arbitrary/THUMBNAIL/${
|
||||||
|
promotion?.name
|
||||||
|
}/qortal_avatar?async=true`}
|
||||||
|
>
|
||||||
|
{promotion?.name?.charAt(0)}
|
||||||
|
</Avatar>
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontWight: 600,
|
||||||
|
fontFamily: "Inter",
|
||||||
|
color: "cadetBlue",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{promotion?.name}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
</Box>
|
||||||
|
<Spacer height="20px"/>
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontWight: 600,
|
||||||
|
fontFamily: "Inter",
|
||||||
|
color: "cadetBlue",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{promotion?.groupName}
|
||||||
|
</Typography>
|
||||||
|
<Spacer height="20px" />
|
||||||
|
<Box sx={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: '20px',
|
||||||
|
alignItems: 'center'
|
||||||
|
}}>
|
||||||
|
{promotion?.isOpen === false && (
|
||||||
|
<LockIcon sx={{
|
||||||
|
color: 'var(--green)'
|
||||||
|
}} />
|
||||||
|
)}
|
||||||
|
{promotion?.isOpen === true && (
|
||||||
|
<NoEncryptionGmailerrorredIcon sx={{
|
||||||
|
color: 'var(--danger)'
|
||||||
|
}} />
|
||||||
|
)}
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontSize: "15px",
|
||||||
|
fontWeight: 600,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{promotion?.isOpen ? 'Public group' : 'Private group' }
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Spacer height="20px" />
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontWight: 600,
|
||||||
|
fontFamily: "Inter",
|
||||||
|
color: "cadetBlue",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{promotion?.data}
|
||||||
|
</Typography>
|
||||||
|
<Spacer height="20px" />
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={(event) => handlePopoverOpen(event, promotion?.groupId)}
|
||||||
|
sx={{
|
||||||
|
fontSize: "12px",
|
||||||
|
color: 'white'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Join Group: {` ${promotion?.groupName}`}
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Spacer height="50px" />
|
||||||
|
</ErrorBoundary>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</Box>
|
</Box>
|
||||||
<Spacer height="20px" />
|
<Spacer height="20px" />
|
||||||
|
|
||||||
@ -726,7 +721,7 @@ export const ListOfGroupPromotions = () => {
|
|||||||
aria-describedby="alert-dialog-description"
|
aria-describedby="alert-dialog-description"
|
||||||
>
|
>
|
||||||
<DialogTitle id="alert-dialog-title">
|
<DialogTitle id="alert-dialog-title">
|
||||||
{"Promote your group to non-members"}
|
{"Promote your group to non-members"}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogContentText id="alert-dialog-description">
|
<DialogContentText id="alert-dialog-description">
|
||||||
|
@ -17,9 +17,9 @@ import { InviteMember } from "./InviteMember";
|
|||||||
import { ListOfInvites } from "./ListOfInvites";
|
import { ListOfInvites } from "./ListOfInvites";
|
||||||
import { ListOfBans } from "./ListOfBans";
|
import { ListOfBans } from "./ListOfBans";
|
||||||
import { ListOfJoinRequests } from "./ListOfJoinRequests";
|
import { ListOfJoinRequests } from "./ListOfJoinRequests";
|
||||||
import { Box, Tab, Tabs } from "@mui/material";
|
import { Box, Card, Tab, Tabs } from "@mui/material";
|
||||||
import { CustomizedSnackbars } from "../Snackbar/Snackbar";
|
import { CustomizedSnackbars } from "../Snackbar/Snackbar";
|
||||||
import { MyContext, isMobile } from "../../App";
|
import { MyContext, getBaseApiReact, isMobile } from "../../App";
|
||||||
import { getGroupMembers, getNames } from "./Group";
|
import { getGroupMembers, getNames } from "./Group";
|
||||||
import { LoadingSnackbar } from "../Snackbar/LoadingSnackbar";
|
import { LoadingSnackbar } from "../Snackbar/LoadingSnackbar";
|
||||||
import { getFee } from "../../background";
|
import { getFee } from "../../background";
|
||||||
@ -59,6 +59,8 @@ export const ManageMembers = ({
|
|||||||
const [infoSnack, setInfoSnack] = React.useState(null);
|
const [infoSnack, setInfoSnack] = React.useState(null);
|
||||||
const [isLoadingMembers, setIsLoadingMembers] = React.useState(false)
|
const [isLoadingMembers, setIsLoadingMembers] = React.useState(false)
|
||||||
const [isLoadingLeave, setIsLoadingLeave] = React.useState(false)
|
const [isLoadingLeave, setIsLoadingLeave] = React.useState(false)
|
||||||
|
const [groupInfo, setGroupInfo] = React.useState(null)
|
||||||
|
|
||||||
const handleChange = (event: React.SyntheticEvent, newValue: number) => {
|
const handleChange = (event: React.SyntheticEvent, newValue: number) => {
|
||||||
setValue(newValue);
|
setValue(newValue);
|
||||||
};
|
};
|
||||||
@ -131,9 +133,20 @@ export const ManageMembers = ({
|
|||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getGroupInfo = async (groupId) => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`${getBaseApiReact()}/groups/${groupId}`
|
||||||
|
);
|
||||||
|
const groupData = await response.json();
|
||||||
|
setGroupInfo(groupData)
|
||||||
|
} catch (error) {}
|
||||||
|
};
|
||||||
|
|
||||||
React.useEffect(()=> {
|
React.useEffect(()=> {
|
||||||
if(selectedGroup?.groupId){
|
if(selectedGroup?.groupId){
|
||||||
getMembers(selectedGroup?.groupId)
|
getMembers(selectedGroup?.groupId)
|
||||||
|
getGroupInfo(selectedGroup?.groupId)
|
||||||
}
|
}
|
||||||
}, [selectedGroup?.groupId])
|
}, [selectedGroup?.groupId])
|
||||||
|
|
||||||
@ -249,12 +262,23 @@ export const ManageMembers = ({
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
<Card sx={{
|
||||||
|
padding: '10px',
|
||||||
|
cursor: 'default',
|
||||||
|
}}>
|
||||||
|
<Box>
|
||||||
|
<Typography>GroupId: {groupInfo?.groupId}</Typography>
|
||||||
|
<Typography>GroupName: {groupInfo?.groupName}</Typography>
|
||||||
|
<Typography>Number of members: {groupInfo?.memberCount}</Typography>
|
||||||
|
</Box>
|
||||||
|
<Spacer height="20px" />
|
||||||
{selectedGroup?.groupId && !isOwner && (
|
{selectedGroup?.groupId && !isOwner && (
|
||||||
<LoadingButton loading={isLoadingLeave} loadingPosition="start"
|
<LoadingButton size="small" loading={isLoadingLeave} loadingPosition="start"
|
||||||
variant="contained" onClick={handleLeaveGroup}>
|
variant="contained" onClick={handleLeaveGroup}>
|
||||||
Leave Group
|
Leave Group
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
)}
|
)}
|
||||||
|
</Card>
|
||||||
|
|
||||||
{value === 0 && (
|
{value === 0 && (
|
||||||
<Box
|
<Box
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { gateways, getApiKeyFromStorage } from "./background";
|
import { gateways, getApiKeyFromStorage } from "./background";
|
||||||
|
import { listOfAllQortalRequests } from "./components/Apps/useQortalMessageListener";
|
||||||
import { addForeignServer, addListItems, adminAction, cancelSellOrder, createAndCopyEmbedLink, createBuyOrder, createPoll, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getWalletBalance, joinGroup, openNewTab, publishMultipleQDNResources, publishQDNResource, removeForeignServer, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, voteOnPoll } from "./qortalRequests/get";
|
import { addForeignServer, addListItems, adminAction, cancelSellOrder, createAndCopyEmbedLink, createBuyOrder, createPoll, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getWalletBalance, joinGroup, openNewTab, publishMultipleQDNResources, publishQDNResource, removeForeignServer, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, voteOnPoll } from "./qortalRequests/get";
|
||||||
import { getData, storeData } from "./utils/chromeStorage";
|
import { getData, storeData } from "./utils/chromeStorage";
|
||||||
|
|
||||||
@ -849,6 +850,26 @@ export const isRunningGateway = async ()=> {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "SHOW_ACTIONS" : {
|
||||||
|
try {
|
||||||
|
|
||||||
|
event.source.postMessage({
|
||||||
|
requestId: request.requestId,
|
||||||
|
action: request.action,
|
||||||
|
payload: listOfAllQortalRequests,
|
||||||
|
type: "backgroundMessageResponse",
|
||||||
|
}, event.origin);
|
||||||
|
} catch (error) {
|
||||||
|
event.source.postMessage({
|
||||||
|
requestId: request.requestId,
|
||||||
|
action: request.action,
|
||||||
|
error: error?.message,
|
||||||
|
type: "backgroundMessageResponse",
|
||||||
|
}, event.origin);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ export const encryptData = async (data, sender) => {
|
|||||||
|
|
||||||
|
|
||||||
export const encryptQortalGroupData = async (data, sender) => {
|
export const encryptQortalGroupData = async (data, sender) => {
|
||||||
let data64 = data.data64;
|
let data64 = data?.data64 || data?.base64;
|
||||||
let groupId = data?.groupId
|
let groupId = data?.groupId
|
||||||
let isAdmins = data?.isAdmins
|
let isAdmins = data?.isAdmins
|
||||||
if(!groupId){
|
if(!groupId){
|
||||||
@ -445,7 +445,7 @@ export const encryptQortalGroupData = async (data, sender) => {
|
|||||||
url
|
url
|
||||||
);
|
);
|
||||||
const resData = await res.text();
|
const resData = await res.text();
|
||||||
const decryptedKey: any = await decryptResource(resData);
|
const decryptedKey: any = await decryptResource(resData, true);
|
||||||
|
|
||||||
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
||||||
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
||||||
@ -479,7 +479,7 @@ url
|
|||||||
url
|
url
|
||||||
);
|
);
|
||||||
const resData = await res.text();
|
const resData = await res.text();
|
||||||
const decryptedKey: any = await decryptResource(resData);
|
const decryptedKey: any = await decryptResource(resData, true);
|
||||||
|
|
||||||
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
||||||
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
||||||
@ -509,7 +509,7 @@ url
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const decryptQortalGroupData = async (data, sender) => {
|
export const decryptQortalGroupData = async (data, sender) => {
|
||||||
let data64 = data.data64;
|
let data64 = data?.data64 || data?.base64;
|
||||||
let groupId = data?.groupId
|
let groupId = data?.groupId
|
||||||
let isAdmins = data?.isAdmins
|
let isAdmins = data?.isAdmins
|
||||||
if(!groupId){
|
if(!groupId){
|
||||||
@ -540,7 +540,7 @@ export const decryptQortalGroupData = async (data, sender) => {
|
|||||||
url
|
url
|
||||||
);
|
);
|
||||||
const resData = await res.text();
|
const resData = await res.text();
|
||||||
const decryptedKey: any = await decryptResource(resData);
|
const decryptedKey: any = await decryptResource(resData, true);
|
||||||
|
|
||||||
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
||||||
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
||||||
@ -571,7 +571,7 @@ url
|
|||||||
url
|
url
|
||||||
);
|
);
|
||||||
const resData = await res.text();
|
const resData = await res.text();
|
||||||
const decryptedKey: any = await decryptResource(resData);
|
const decryptedKey: any = await decryptResource(resData, true);
|
||||||
|
|
||||||
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
||||||
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
||||||
@ -598,7 +598,7 @@ url
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const encryptDataWithSharingKey = async (data, sender) => {
|
export const encryptDataWithSharingKey = async (data, sender) => {
|
||||||
let data64 = data.data64;
|
let data64 = data?.data64 || data?.base64;
|
||||||
let publicKeys = data.publicKeys || [];
|
let publicKeys = data.publicKeys || [];
|
||||||
if (data.fileId) {
|
if (data.fileId) {
|
||||||
data64 = await getFileFromContentScript(data.fileId);
|
data64 = await getFileFromContentScript(data.fileId);
|
||||||
@ -3697,7 +3697,10 @@ export const createAndCopyEmbedLink = async (data, isFromExtension) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getHostedData = async (data, isFromExtension) => {
|
export const getHostedData = async (data, isFromExtension) => {
|
||||||
|
const isGateway = await isRunningGateway();
|
||||||
|
if (isGateway) {
|
||||||
|
throw new Error("This action cannot be done through a gateway");
|
||||||
|
}
|
||||||
const resPermission = await getUserPermission(
|
const resPermission = await getUserPermission(
|
||||||
{
|
{
|
||||||
text1: "Do you give this application permission to",
|
text1: "Do you give this application permission to",
|
||||||
@ -3709,19 +3712,20 @@ export const getHostedData = async (data, isFromExtension) => {
|
|||||||
|
|
||||||
if(accepted){
|
if(accepted){
|
||||||
const limit = data?.limit ? data?.limit : 20;
|
const limit = data?.limit ? data?.limit : 20;
|
||||||
const query = data?.query ? data?.query : undefined
|
const query = data?.query ? data?.query : ""
|
||||||
const offset = data?.offset ? data?.offset : 0
|
const offset = data?.offset ? data?.offset : 0
|
||||||
|
|
||||||
try {
|
let urlPath = `/arbitrary/hosted/resources/?limit=${limit}&offset=${offset}`
|
||||||
|
if(query){
|
||||||
const url = await createEndpoint(`/arbitrary/hosted/resources/?limit=${limit}&query=${query}&offset=${offset}`);
|
urlPath = urlPath + `&query=${query}`
|
||||||
const response = await fetch(url);
|
|
||||||
const data = await response.json();
|
|
||||||
return data
|
|
||||||
} catch (error) {
|
|
||||||
throw error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const url = await createEndpoint(urlPath);
|
||||||
|
const response = await fetch(url);
|
||||||
|
const dataResponse = await response.json();
|
||||||
|
return dataResponse
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error("User declined to get list of hosted resources");
|
throw new Error("User declined to get list of hosted resources");
|
||||||
}
|
}
|
||||||
@ -3729,6 +3733,10 @@ export const getHostedData = async (data, isFromExtension) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const deleteHostedData = async (data, isFromExtension) => {
|
export const deleteHostedData = async (data, isFromExtension) => {
|
||||||
|
const isGateway = await isRunningGateway();
|
||||||
|
if (isGateway) {
|
||||||
|
throw new Error("This action cannot be done through a gateway");
|
||||||
|
}
|
||||||
const requiredFields = ["hostedData"];
|
const requiredFields = ["hostedData"];
|
||||||
const missingFields: string[] = [];
|
const missingFields: string[] = [];
|
||||||
requiredFields.forEach((field) => {
|
requiredFields.forEach((field) => {
|
||||||
@ -3750,7 +3758,7 @@ export const deleteHostedData = async (data, isFromExtension) => {
|
|||||||
|
|
||||||
for (const hostedDataItem of hostedData){
|
for (const hostedDataItem of hostedData){
|
||||||
try {
|
try {
|
||||||
const url = await createEndpoint(`/arbitrary/resource/${hostedDataItem.service}/${hostedDataItem.name}/${hostedDataItem.identifer}`);
|
const url = await createEndpoint(`/arbitrary/resource/${hostedDataItem.service}/${hostedDataItem.name}/${hostedDataItem.identifier}`);
|
||||||
await fetch(url, {
|
await fetch(url, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user