Don't reload song on save
@@ -117,13 +117,24 @@ const MusicPageUge = () => {
const error = useSelector(
(state: RootState) => state.trackerDocument.present.error
);
+
+ const [selectedSongPath, setSelectedSongPath] = useState("");
+ const [selectedSongType, setSelectedSongType] = useState("");
+ useEffect(() => {
+ if (selectedSong) {
+ setSelectedSongPath(
+ `${assetFilename(projectRoot, "music", selectedSong)}`
+ );
+ setSelectedSongType(selectedSong.type || "");
+ }
+ }, [projectRoot, selectedSong]);
+
useEffect(() => {
- if (selectedSong && selectedSong.type === "uge") {
+ if (selectedSongPath !== "" && selectedSongType === "uge") {
dispatch({ type: "@@TRACKER_INIT" });
- const path = `${assetFilename(projectRoot, "music", selectedSong)}`;
- dispatch(loadSongFile(path));
+ dispatch(loadSongFile(selectedSongPath));
}
- }, [dispatch, projectRoot, selectedSong]);
+ }, [dispatch, selectedSongPath, selectedSongType]);
const [leftPaneWidth, setLeftPaneSize, startLeftPaneResize] = useResizable({
initialSize: navigatorSidebarWidth,
