This commit is contained in:
PhilReact 2025-03-02 20:05:35 +02:00
parent 24b2f35e63
commit 852bb13a71
6 changed files with 60 additions and 20 deletions

View File

@ -249,11 +249,12 @@ export class ElectronCapacitorApp {
export function setupContentSecurityPolicy(customScheme: string): void { export function setupContentSecurityPolicy(customScheme: string): void {
session.defaultSession.webRequest.onHeadersReceived((details: any, callback) => { session.defaultSession.webRequest.onHeadersReceived((details: any, callback) => {
const allowedSources = ["'self'", customScheme, ...domainHolder.allowedDomains]; const allowedSources = ["'self'", customScheme, ...domainHolder.allowedDomains];
const connectSources = [...allowedSources];
const frameSources = [ const frameSources = [
"'self'", "'self'",
'http://localhost:*', 'http://localhost:*',
'https://localhost:*', 'https://localhost:*',
'ws://localhost:*',
'ws://127.0.0.1:*',
'http://127.0.0.1:*', 'http://127.0.0.1:*',
'https://127.0.0.1:*', 'https://127.0.0.1:*',
...allowedSources, ...allowedSources,
@ -261,13 +262,13 @@ export function setupContentSecurityPolicy(customScheme: string): void {
// Create the Content Security Policy (CSP) string // Create the Content Security Policy (CSP) string
const csp = ` const csp = `
default-src 'self' ${allowedSources.join(' ')}; default-src 'self' ${frameSources.join(' ')};
frame-src ${frameSources.join(' ')}; frame-src ${frameSources.join(' ')};
script-src 'self' 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' ${allowedSources.join(' ')}; script-src 'self' 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' ${frameSources.join(' ')};
object-src 'self'; object-src 'self';
connect-src 'self' blob: ${connectSources.join(' ')}; connect-src 'self' blob: ${frameSources.join(' ')};
img-src 'self' data: blob: ${allowedSources.join(' ')}; img-src 'self' data: blob: ${frameSources.join(' ')};
media-src 'self' blob: ${allowedSources.join(' ')}; media-src 'self' blob: ${frameSources.join(' ')};
style-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';
font-src 'self' data:; font-src 'self' data:;
`.replace(/\s+/g, ' ').trim(); `.replace(/\s+/g, ' ').trim();

View File

@ -1443,7 +1443,7 @@ function App() {
</> </>
) : ( ) : (
<> <>
<MainAvatar myName={userInfo?.name} /> <MainAvatar setOpenSnack={setOpenSnack} setInfoSnack={setInfoSnack} myName={userInfo?.name} balance={balance} />
<Spacer height="32px" /> <Spacer height="32px" />
<TextP <TextP
sx={{ sx={{
@ -3294,7 +3294,7 @@ function App() {
aria-labelledby="alert-dialog-title" aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description" aria-describedby="alert-dialog-description"
> >
<DialogTitle id="alert-dialog-title">{"Warning"}</DialogTitle> <DialogTitle id="alert-dialog-title">{"LOGOUT"}</DialogTitle>
<DialogContent> <DialogContent>
<DialogContentText id="alert-dialog-description"> <DialogContentText id="alert-dialog-description">
{messageUnsavedChanges.message} {messageUnsavedChanges.message}
@ -3336,7 +3336,6 @@ function App() {
flexDirection: "column", flexDirection: "column",
alignItems: "center", alignItems: "center",
justifyContent: "flex-start", justifyContent: "flex-start",
minHeight: "400px",
maxHeight: "90vh", maxHeight: "90vh",
overflow: "auto", overflow: "auto",
}} }}

View File

@ -941,7 +941,7 @@ export async function getBalanceInfo() {
const validApi = await getBaseApi(); const validApi = await getBaseApi();
const response = await fetch(validApi + "/addresses/balance/" + address); const response = await fetch(validApi + "/addresses/balance/" + address);
if (!response?.ok) throw new Error("Cannot fetch balance"); if (!response?.ok) throw new Error("0 QORT in your balance");
const data = await response.json(); const data = await response.json();
return data; return data;
} }
@ -1101,7 +1101,7 @@ export const getLastRef = async () => {
const response = await fetch( const response = await fetch(
validApi + "/addresses/lastreference/" + address validApi + "/addresses/lastreference/" + address
); );
if (!response?.ok) throw new Error("Cannot fetch balance"); if (!response?.ok) throw new Error("0 QORT in your balance");
const data = await response.text(); const data = await response.text();
return data; return data;
}; };

View File

@ -809,6 +809,7 @@ export const ListOfGroupPromotions = () => {
value={selectedGroup} value={selectedGroup}
label="Groups where you are an admin" label="Groups where you are an admin"
onChange={(e) => setSelectedGroup(e.target.value)} onChange={(e) => setSelectedGroup(e.target.value)}
variant="outlined"
> >
{myGroupsWhereIAmAdmin?.map((group) => { {myGroupsWhereIAmAdmin?.map((group) => {
return ( return (

View File

@ -7,8 +7,9 @@ import ImageUploader from "../common/ImageUploader";
import { getFee } from "../background"; import { getFee } from "../background";
import { fileToBase64 } from "../utils/fileReading"; import { fileToBase64 } from "../utils/fileReading";
import { LoadingButton } from "@mui/lab"; import { LoadingButton } from "@mui/lab";
import ErrorIcon from '@mui/icons-material/Error';
export const MainAvatar = ({ myName }) => { export const MainAvatar = ({ myName, balance, setOpenSnack, setInfoSnack }) => {
const [hasAvatar, setHasAvatar] = useState(false); const [hasAvatar, setHasAvatar] = useState(false);
const [avatarFile, setAvatarFile] = useState(null); const [avatarFile, setAvatarFile] = useState(null);
const [tempAvatar, setTempAvatar] = useState(null) const [tempAvatar, setTempAvatar] = useState(null)
@ -52,10 +53,11 @@ const [isLoading, setIsLoading] = useState(false)
checkIfAvatarExists(); checkIfAvatarExists();
}, [myName]); }, [myName]);
const publishAvatar = async ()=> { const publishAvatar = async ()=> {
try { try {
const fee = await getFee('ARBITRARY') const fee = await getFee('ARBITRARY')
if(+balance < +fee.fee) throw new Error(`Publishing an Avatar requires ${fee.fee}`)
await show({ await show({
message: "Would you like to publish an avatar?" , message: "Would you like to publish an avatar?" ,
publishFee: fee.fee + ' QORT' publishFee: fee.fee + ' QORT'
@ -84,7 +86,13 @@ const [isLoading, setIsLoading] = useState(false)
setTempAvatar(`data:image/webp;base64,${avatarBase64}`) setTempAvatar(`data:image/webp;base64,${avatarBase64}`)
handleClose() handleClose()
} catch (error) { } catch (error) {
if (error?.message) {
setOpenSnack(true)
setInfoSnack({
type: "error",
message: error?.message,
});
}
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
@ -113,7 +121,7 @@ const [isLoading, setIsLoading] = useState(false)
change avatar change avatar
</Typography> </Typography>
</ButtonBase> </ButtonBase>
<PopoverComp avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} /> <PopoverComp myName={myName} avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} />
</> </>
); );
} }
@ -141,7 +149,7 @@ const [isLoading, setIsLoading] = useState(false)
change avatar change avatar
</Typography> </Typography>
</ButtonBase> </ButtonBase>
<PopoverComp avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} /> <PopoverComp myName={myName} avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} />
</> </>
); );
} }
@ -159,13 +167,13 @@ const [isLoading, setIsLoading] = useState(false)
set avatar set avatar
</Typography> </Typography>
</ButtonBase> </ButtonBase>
<PopoverComp avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} /> <PopoverComp myName={myName} avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} />
</> </>
); );
}; };
const PopoverComp = ({avatarFile, setAvatarFile, id, open, anchorEl, handleClose, publishAvatar, isLoading}) => { const PopoverComp = ({avatarFile, setAvatarFile, id, open, anchorEl, handleClose, publishAvatar, isLoading, myName}) => {
return ( return (
<Popover <Popover
id={id} id={id}
@ -194,8 +202,21 @@ const PopoverComp = ({avatarFile, setAvatarFile, id, open, anchorEl, handleClose
</ImageUploader> </ImageUploader>
{avatarFile?.name} {avatarFile?.name}
<Spacer height="25px" /> <Spacer height="25px" />
{!myName && (
<LoadingButton loading={isLoading} disabled={!avatarFile} onClick={publishAvatar} variant="contained"> <Box sx={{
display: 'flex',
gap: '5px',
alignItems: 'center'
}}>
<ErrorIcon sx={{
color: 'white'
}} />
<Typography>A registered name is required to set an avatar</Typography>
</Box>
)}
<Spacer height="25px" />
<LoadingButton loading={isLoading} disabled={!avatarFile || !myName} onClick={publishAvatar} variant="contained">
Publish avatar Publish avatar
</LoadingButton> </LoadingButton>
</Box> </Box>

View File

@ -44,6 +44,24 @@ const theme = createTheme({
color: '#b0b0b0', // Lighter text for body2, often used for secondary text color: '#b0b0b0', // Lighter text for body2, often used for secondary text
}, },
}, },
components: {
MuiOutlinedInput: {
styleOverrides: {
root: {
".MuiOutlinedInput-notchedOutline": {
borderColor: "white", // ⚪ Default outline color
},
},
},
},
MuiSelect: {
styleOverrides: {
icon: {
color: "white", // ✅ Caret (dropdown arrow) color
},
},
},
},
}); });
export default theme; export default theme;