Skip to content

Commit

Permalink
fixes + emudecky
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoonDorise committed Oct 31, 2024
1 parent 85fb605 commit 74fd886
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
44 changes: 42 additions & 2 deletions src/renderer/pages/MigrationPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function MigrationPage() {
const { t, i18n } = useTranslation();
const ipcChannel = window.electron.ipcRenderer;
const { state, setState } = useContext(GlobalContext);
const { storage, storagePath } = state;
const { storage, storagePath, system } = state;
const [statePage, setStatePage] = useState({
disabledNext: storage === null,
disabledBack: false,
Expand All @@ -25,6 +25,7 @@ function MigrationPage() {
storagePathDestination: undefined,
modal: undefined,
dom: undefined,
hddrives: [],
});
const {
disabledNext,
Expand All @@ -37,6 +38,7 @@ function MigrationPage() {
storageDestination,
modal,
dom,
hddrives,
} = statePage;

const storageSet = (storageName) => {
Expand Down Expand Up @@ -129,9 +131,44 @@ function MigrationPage() {
});
};

const getHDdrives = () => {
ipcChannel.sendMessage('emudeck', ['getLocations|||getLocations']);

ipcChannel.once('getLocations', (message) => {
const hdrives = message.stdout;

const hdrivesCleanup = hdrives.replace(/(\r\n|\r|\n)/g, '');
const jsonDrives = JSON.parse(hdrivesCleanup);

setStatePage({
...statePage,
modal: false,
hddrives: jsonDrives,
});
console.log({ statePage });
});
};

// Do we have a valid SD Card?
useEffect(() => {
checkSDValid();
if (navigator.onLine === false) {
navigate('/error');
return;
}

if (system !== 'win32') {
checkSDValid();
} else if (system === 'win32') {
const modalData = {
active: true,
header: <span className="h4">Collecting Drives Names</span>,
body: <p>This will take a few seconds. Please wait...</p>,
css: 'emumodal--xs',
};
setStatePage({ ...statePage, modal: modalData });
// We get the drives
getHDdrives();
}
}, []);

// We make sure we get the new SD Card name on State when we populate it if the user selected the SD Card in the previous installation
Expand Down Expand Up @@ -205,6 +242,9 @@ function MigrationPage() {
onClick={storageSet}
onClickStart={startMigration}
storage={storage}
showSDCard={system !== 'win32'}
showInternal={system !== 'win32'}
hddrives={system === 'win32' ? hddrives : false}
storageDestination={storageDestination}
storagePath={storagePath}
storagePathDestination={storagePathDestination}
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/pages/RomStoragePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ function RomStoragePage() {
ipcChannel.sendMessage('emudeck', ['customLocation|||customLocation']);

ipcChannel.once('customLocation', (message) => {
const stdout = message.stdout.replace('\n', '');
let stdout = message.stdout.replace('\n', '');

const storagePath = stdout;
const storagePath = stdout.replaceAll('\\', '/');

setStatePage({
...statePage,
Expand Down Expand Up @@ -499,7 +499,7 @@ function RomStoragePage() {
sdCardValid={sdCardValid}
showSDCard={system !== 'win32'}
showInternal={system !== 'win32'}
showCustom={!!(system !== 'win32' && system !== 'darwin')}
showCustom={true}
hddrives={system === 'win32' ? hddrives : false}
reloadSDcard={checkSDValid}
sdCardName={sdCardName}
Expand Down

0 comments on commit 74fd886

Please sign in to comment.