Skip to content

Commit

Permalink
fix: remove redundant async
Browse files Browse the repository at this point in the history
  • Loading branch information
jooy2 committed May 6, 2024
1 parent a202bf0 commit ed461e7
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/renderer/components/dialogs/ModalLocalStorageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const ModalLocalStorageView = () => {
[stateAppScreen.appConfigLanguage],
);

const handleDialogClose = async () => {
const handleDialogClose = () => {
setData(JSON.stringify(localStorage));
setError(false);
dispatch(setConfig({ dialogLocalStorageViewOpen: false }));
Expand All @@ -54,7 +54,7 @@ const ModalLocalStorageView = () => {
localStorage.setItem(key, value.toString());
}
});
await handleDialogClose();
handleDialogClose();
} catch {
setError(true);
}
Expand All @@ -69,7 +69,7 @@ const ModalLocalStorageView = () => {
localStorage.setItem('i18nextLng', i18LngValue);
setData(JSON.stringify(localStorage));
handleOpenConfirm(false);
await handleDialogClose();
handleDialogClose();
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/dialogs/ModalMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ModalMetadata = () => {
const stateAppScreen = useSelector((state: RootState) => state.appScreen);
const dispatch = useDispatch();

const handleDialogClose = async () => {
const handleDialogClose = () => {
dispatch(setConfig({ dialogMetadataOpen: false }));
};

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/layouts/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ const Header = ({ title, withBackButton, withRefresh = false }) => {
}
};

const handleOpenMetadata = async () => {
const handleOpenMetadata = () => {
dispatch(setConfig({ dialogMetadataOpen: true }));
};

const handleFlashEmulatePlayerVersionChange = async (event) => {
const handleFlashEmulatePlayerVersionChange = (event) => {
dispatch(setConfig({ appConfigEmulatePlayerVersion: event.target.value }));
};

Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/views/FlashPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const FlashPlayer = ({ url = '', autoplay = true, filePath = '', header = true }
}
};

const handleMute = async () => {
const handleMute = () => {
if (stateAppScreen.flashVolume === 0) {
rufflePlayer.volume = 1;
dispatch(setConfig({ flashVolume: 100 }));
Expand All @@ -51,7 +51,7 @@ const FlashPlayer = ({ url = '', autoplay = true, filePath = '', header = true }
}
};

const handleVolumeSliderChange = async (event, newValue) => {
const handleVolumeSliderChange = (event, newValue) => {
rufflePlayer.volume = newValue / 100;
dispatch(setConfig({ flashVolume: newValue }));
};
Expand Down Expand Up @@ -125,7 +125,7 @@ const FlashPlayer = ({ url = '', autoplay = true, filePath = '', header = true }
}

rufflePlayer.id = 'player';
rufflePlayer.addEventListener('loadedmetadata', async () => {
rufflePlayer.addEventListener('loadedmetadata', () => {
const metaData = rufflePlayer?.metadata;
dispatch(
setConfig({
Expand Down
10 changes: 6 additions & 4 deletions src/renderer/screens/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Explorer = () => {
const [loading, setLoading] = useState(false);
const [flashContentError, setFlashContentError] = useState(false);
const [errorMessage, setErrorMessage] = useState('');
const runFlash = async (fileName, filePath) => {
const runFlash = (fileName: string, filePath: string) => {
setLoading(true);
dispatch(
setConfig({
Expand Down Expand Up @@ -66,7 +66,9 @@ const Explorer = () => {
setErrorMessage(t('notice:wrong-file-type') as SetStateAction<string>);
return false;
}
await runFlash(file?.name, filePath);

runFlash(file?.name, filePath);

return true;
}, []);
const { getRootProps, getInputProps } = useDropzone({
Expand All @@ -87,7 +89,7 @@ const Explorer = () => {
});
};

const handleRemoveRecentFiles = async () => {
const handleRemoveRecentFiles = () => {
window.mainApi.send('removeAllRecentFile');
dispatch(
setConfig({
Expand All @@ -107,7 +109,7 @@ const Explorer = () => {

window.mainApi.receive('receiveFileExist', async (event, argument) => {
if (argument.exist) {
await runFlash(argument.name, argument.path);
runFlash(argument.name, argument.path);
} else {
window.mainApi.send('removeRecentFile', {
path: argument.path,
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/screens/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Main = () => {

const handleVersionCheck = async () => true; // TODO version check

const runFromExplorer = async (filePath: string): Promise<void> => {
const runFromExplorer = (filePath: string): void => {
dispatch(
setConfig({
flashFileName: filePath.split('\\').pop(),
Expand Down Expand Up @@ -91,14 +91,14 @@ const Main = () => {
await i18n.changeLanguage(configs.language);
}

window.mainApi.receive('receiveOpenFile', async (openFileEvent, receivePath) => {
await runFromExplorer(receivePath);
window.mainApi.receive('receiveOpenFile', (openFileEvent, receivePath) => {
runFromExplorer(receivePath);
});

setLoadMsg(3);

if (filePath) {
await runFromExplorer(filePath);
runFromExplorer(filePath);
} else {
navigate('/explorer');
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/screens/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Player = () => {
const navigate = useNavigate();

useEffect(() => {
window.mainApi.receive('receiveResumeToExplorer', async () => {
window.mainApi.receive('receiveResumeToExplorer', () => {
dispatch(
setConfig({
flashFileName: '',
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/screens/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Settings = () => {
);
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');

const handleRadioChange = async (event): Promise<void> => {
const handleRadioChange = (event): void => {
const { value } = event.target;
switch (event.target.name) {
case 'themeCheck':
Expand Down Expand Up @@ -77,8 +77,9 @@ const Settings = () => {
}
};

const handleCheckboxChange = async (event): Promise<void> => {
const handleCheckboxChange = (event): void => {
const value = event.target.checked;

switch (event.target.name) {
case 'hideHeaderChecked':
setHideHeaderChecked(value);
Expand Down Expand Up @@ -139,7 +140,7 @@ const Settings = () => {
window.mainApi.send('resetAppConfig');
};

const handleOpenLocalStorageViewModal = async (): Promise<void> => {
const handleOpenLocalStorageViewModal = (): void => {
dispatch(setConfig({ dialogLocalStorageViewOpen: true }));
};

Expand Down

0 comments on commit ed461e7

Please sign in to comment.