From 852bb13a7197a23b57a4a67b9b423d024e6357ca Mon Sep 17 00:00:00 2001 From: PhilReact Date: Sun, 2 Mar 2025 20:05:35 +0200 Subject: [PATCH] fixes --- electron/src/setup.ts | 13 ++++--- src/App.tsx | 5 +-- src/background.ts | 4 +- .../Group/ListOfGroupPromotions.tsx | 1 + src/components/MainAvatar.tsx | 39 ++++++++++++++----- src/main.tsx | 18 +++++++++ 6 files changed, 60 insertions(+), 20 deletions(-) diff --git a/electron/src/setup.ts b/electron/src/setup.ts index 6fab164..d1fb925 100644 --- a/electron/src/setup.ts +++ b/electron/src/setup.ts @@ -249,11 +249,12 @@ export class ElectronCapacitorApp { export function setupContentSecurityPolicy(customScheme: string): void { session.defaultSession.webRequest.onHeadersReceived((details: any, callback) => { const allowedSources = ["'self'", customScheme, ...domainHolder.allowedDomains]; - const connectSources = [...allowedSources]; const frameSources = [ "'self'", 'http://localhost:*', 'https://localhost:*', + 'ws://localhost:*', + 'ws://127.0.0.1:*', 'http://127.0.0.1:*', 'https://127.0.0.1:*', ...allowedSources, @@ -261,13 +262,13 @@ export function setupContentSecurityPolicy(customScheme: string): void { // Create the Content Security Policy (CSP) string const csp = ` - default-src 'self' ${allowedSources.join(' ')}; + default-src 'self' ${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'; - connect-src 'self' blob: ${connectSources.join(' ')}; - img-src 'self' data: blob: ${allowedSources.join(' ')}; - media-src 'self' blob: ${allowedSources.join(' ')}; + connect-src 'self' blob: ${frameSources.join(' ')}; + img-src 'self' data: blob: ${frameSources.join(' ')}; + media-src 'self' blob: ${frameSources.join(' ')}; style-src 'self' 'unsafe-inline'; font-src 'self' data:; `.replace(/\s+/g, ' ').trim(); diff --git a/src/App.tsx b/src/App.tsx index 5eca049..f6a6a7d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1443,7 +1443,7 @@ function App() { ) : ( <> - + - {"Warning"} + {"LOGOUT"} {messageUnsavedChanges.message} @@ -3336,7 +3336,6 @@ function App() { flexDirection: "column", alignItems: "center", justifyContent: "flex-start", - minHeight: "400px", maxHeight: "90vh", overflow: "auto", }} diff --git a/src/background.ts b/src/background.ts index ad8ddf3..96febcd 100644 --- a/src/background.ts +++ b/src/background.ts @@ -941,7 +941,7 @@ export async function getBalanceInfo() { const validApi = await getBaseApi(); 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(); return data; } @@ -1101,7 +1101,7 @@ export const getLastRef = async () => { const response = await fetch( 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(); return data; }; diff --git a/src/components/Group/ListOfGroupPromotions.tsx b/src/components/Group/ListOfGroupPromotions.tsx index a983f56..afeff14 100644 --- a/src/components/Group/ListOfGroupPromotions.tsx +++ b/src/components/Group/ListOfGroupPromotions.tsx @@ -809,6 +809,7 @@ export const ListOfGroupPromotions = () => { value={selectedGroup} label="Groups where you are an admin" onChange={(e) => setSelectedGroup(e.target.value)} + variant="outlined" > {myGroupsWhereIAmAdmin?.map((group) => { return ( diff --git a/src/components/MainAvatar.tsx b/src/components/MainAvatar.tsx index b5f8e44..faca10a 100644 --- a/src/components/MainAvatar.tsx +++ b/src/components/MainAvatar.tsx @@ -7,8 +7,9 @@ import ImageUploader from "../common/ImageUploader"; import { getFee } from "../background"; import { fileToBase64 } from "../utils/fileReading"; 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 [avatarFile, setAvatarFile] = useState(null); const [tempAvatar, setTempAvatar] = useState(null) @@ -52,10 +53,11 @@ const [isLoading, setIsLoading] = useState(false) checkIfAvatarExists(); }, [myName]); + const publishAvatar = async ()=> { try { const fee = await getFee('ARBITRARY') - + if(+balance < +fee.fee) throw new Error(`Publishing an Avatar requires ${fee.fee}`) await show({ message: "Would you like to publish an avatar?" , publishFee: fee.fee + ' QORT' @@ -84,7 +86,13 @@ const [isLoading, setIsLoading] = useState(false) setTempAvatar(`data:image/webp;base64,${avatarBase64}`) handleClose() } catch (error) { - + if (error?.message) { + setOpenSnack(true) + setInfoSnack({ + type: "error", + message: error?.message, + }); + } } finally { setIsLoading(false); } @@ -113,7 +121,7 @@ const [isLoading, setIsLoading] = useState(false) change avatar - + ); } @@ -141,7 +149,7 @@ const [isLoading, setIsLoading] = useState(false) change avatar - + ); } @@ -159,13 +167,13 @@ const [isLoading, setIsLoading] = useState(false) set avatar - + ); }; -const PopoverComp = ({avatarFile, setAvatarFile, id, open, anchorEl, handleClose, publishAvatar, isLoading}) => { +const PopoverComp = ({avatarFile, setAvatarFile, id, open, anchorEl, handleClose, publishAvatar, isLoading, myName}) => { return ( {avatarFile?.name} - - + {!myName && ( + + + A registered name is required to set an avatar + + )} + + + Publish avatar diff --git a/src/main.tsx b/src/main.tsx index dcaf3ca..22bba47 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -44,6 +44,24 @@ const theme = createTheme({ 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;