Skip to content

Commit

Permalink
Hotfix: 0.3.2 (#5)
Browse files Browse the repository at this point in the history
* add missing dispatch for create form

* revert to alt tick sound

* properly handle file deletion in storage methods

* add changeset
  • Loading branch information
officialMECH authored Nov 13, 2024
1 parent 01a2fdb commit 116b619
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beatmapper",
"version": "0.3.1",
"version": "0.3.2",
"type": "module",
"private": true,
"packageManager": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { default as defaultSfxPath } from "./audio/tick.mp3";
export { default as defaultSfxPath } from "./audio/tick-alt.mp3";

export { default as oswaldGlyphs } from "./fonts/oswald.json";

Expand Down
5 changes: 3 additions & 2 deletions src/components/AddSongForm/AddSongForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { COLORS, DIFFICULTIES, MEDIA_ROW_HEIGHT, UNIT } from "$/constants";
import { getSongIdFromName } from "$/helpers/song.helpers";
import { saveLocalCoverArtFile, saveSongFile } from "$/services/file.service";
import { createNewSong } from "$/store/actions";
import { useAppSelector } from "$/store/hooks";
import { useAppDispatch, useAppSelector } from "$/store/hooks";
import { getAllSongIds } from "$/store/selectors";

import Button from "../Button";
Expand All @@ -21,6 +21,7 @@ import SongPicker from "./SongPicker";

const AddSongForm = () => {
const currentSongIds = useAppSelector(getAllSongIds);
const dispatch = useAppDispatch();
const navigate = useNavigate();

// These files are sent to the redux middleware.
Expand Down Expand Up @@ -72,7 +73,7 @@ const AddSongForm = () => {
const [coverArtFilename] = await saveLocalCoverArtFile(songId, coverArtFile);
const [songFilename] = await saveSongFile(songId, songFile);

createNewSong({ coverArtFilename, coverArtFile, songFilename, songFile, songId, name, subName, artistName, bpm, offset, selectedDifficulty });
dispatch(createNewSong({ coverArtFilename, coverArtFile, songFilename, songFile, songId, name, subName, artistName, bpm, offset, selectedDifficulty }));

// Wait for the `createNewSong` action to flush, and then redirect the user to the new song page!
window.requestAnimationFrame(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/SongRowActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const SongRowActions = ({ songId, size }: Props) => {

const handleDelete = () => {
if (window.confirm("Are you sure? This action cannot be undone 😱")) {
dispatch(deleteSong({ songId }));
dispatch(deleteSong({ songId, coverArtFilename: song.coverArtFilename, songFilename: song.songFilename, difficultiesById: song.difficultiesById }));
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export function saveInfoDat(songId: SongId, infoContent: string) {
* - All difficulty beatmaps
* - Info.dat
*/
export async function deleteAllSongFiles(song: App.Song) {
export async function deleteAllSongFiles(song: Pick<App.Song, "id" | "songFilename" | "coverArtFilename" | "difficultiesById">) {
const { id, songFilename, coverArtFilename, difficultiesById } = song;

const infoDatName = getFilenameForThing(id, FileType.INFO);
Expand Down
2 changes: 1 addition & 1 deletion src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export const undoEvents = createAction("UNDO_EVENTS");

export const redoEvents = createAction("REDO_EVENTS");

export const deleteSong = createAction("DELETE_SONG", (args: { songId: SongId }) => {
export const deleteSong = createAction("DELETE_SONG", (args: { songId: SongId } & Pick<App.Song, "difficultiesById" | "coverArtFilename" | "songFilename">) => {
return { payload: { ...args } };
});

Expand Down
8 changes: 3 additions & 5 deletions src/store/middleware/song.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,9 @@ export default function createSongMiddleware() {
});
instance.startListening({
actionCreator: deleteSong,
effect: (action, api) => {
const state = api.getState();
const { songId } = action.payload;
const song = getSongById(state, songId);
deleteAllSongFiles(song);
effect: async (action) => {
const { songId: id, difficultiesById, songFilename, coverArtFilename } = action.payload;
await deleteAllSongFiles({ id, difficultiesById, songFilename, coverArtFilename });
},
});

Expand Down

0 comments on commit 116b619

Please sign in to comment.