fix: settings window was unresponsive on first start because of fs.mkdir that wasn't awaited

This commit is contained in:
Rick van Lieshout 2023-05-16 23:41:00 +02:00
parent 8036cbb919
commit a7dee5c2c9

View File

@ -31,12 +31,13 @@ export const getOptions = (array: string[]) => {
* @param directory to read from. Will be created if it doesn't exist * @param directory to read from. Will be created if it doesn't exist
* @returns * @returns
*/ */
export const getThemeListFromDirectory = (directory: string) => { export const getThemeListFromDirectory = (directory: string): string[] => {
try { try {
makeUserThemesDirectory(directory); makeUserThemesDirectory(directory);
return fs.readdirSync(directory).filter(cssFilter).sort(sort); return fs.readdirSync(directory).filter(cssFilter).sort(sort);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
return [];
} }
}; };
@ -46,9 +47,7 @@ export const getThemeListFromDirectory = (directory: string) => {
*/ */
export const makeUserThemesDirectory = (directory: string) => { export const makeUserThemesDirectory = (directory: string) => {
try { try {
fs.mkdir(directory, { recursive: true }, (err) => { fs.mkdirSync(directory, { recursive: true });
if (err) throw err;
});
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }