Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.4.0 bug patch✨ #46

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion muzik-offline/src/interface/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const App = () => {
<Route path="/AllAlbums" element={<AllAlbums/>}/>
<Route path="/AllGenres" element={<AllGenres/>}/>
<Route path="/AllPlaylists" element={<AllPlaylists/>}/>
<Route path="/SearchPage" element={<SearchPage/>}/>
<Route path="/SearchPage/*" element={<SearchPage/>}/>
<Route path="/AlbumDetails/:album_key/:artist_name" element={<AlbumDetails/>}/>
<Route path="/ArtistCatalogue/:artist_name" element={<ArtistCatalogue/>}/>
<Route path="/GenreView/:genre_key" element={<GenreView/>}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const HeaderLinuxOS: FunctionComponent<HeaderLinuxOSProps> = (props: HeaderLinux
id="gsearch"
placeholder="Search..."
onChange={captureSearch}
onFocus={() => navigate("/SearchPage")}/>
onFocus={() => navigate("/SearchPage/songs")}/>
{
searchText !== "" &&
<motion.div onClick={clearSearch} whileTap={{scale: 0.97}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const HeaderMacOS: FunctionComponent<HeaderMacOSProps> = (props: HeaderMacOSPro
id="gsearch"
placeholder="Search..."
onChange={captureSearch}
onFocus={() => navigate("/SearchPage")}/>
onFocus={() => navigate("/SearchPage/songs")}/>
{
searchText !== "" &&
<motion.div onClick={clearSearch} whileTap={{scale: 0.97}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const HeaderWindows: FunctionComponent<HeaderWindowsProps> = (props: HeaderWindo

const navigate = useNavigate();
const [searchText, setSearchText] = useState<string>("");
const [isFS, setIsFS] = useState<boolean>(false);
const { setSearch } = useSearchStore((state) => { return { setSearch: state.setSearch}; });

function captureSearch(e: any){setSearchText(e.target.value);}
Expand Down Expand Up @@ -65,6 +66,8 @@ const HeaderWindows: FunctionComponent<HeaderWindowsProps> = (props: HeaderWindo
if(maximizebtn)maximizebtn.style.visibility = "visible";
if(restorebtn)restorebtn.style.visibility = "hidden";
}
const fs_conf: boolean = await appWindow.isFullscreen();
setIsFS(fs_conf);
}

window.addEventListener("resize", handleScreenResize);
Expand Down Expand Up @@ -104,7 +107,7 @@ const HeaderWindows: FunctionComponent<HeaderWindowsProps> = (props: HeaderWindo
id="gsearch"
placeholder="Search..."
onChange={captureSearch}
onFocus={() => navigate("/SearchPage")}/>
onFocus={() => navigate("/SearchPage/songs")}/>
{
searchText !== "" &&
<motion.div onClick={clearSearch} whileTap={{scale: 0.97}}>
Expand All @@ -117,7 +120,7 @@ const HeaderWindows: FunctionComponent<HeaderWindowsProps> = (props: HeaderWindo
<Empty_user />
<h2>settings</h2>
</motion.div>
<div className="window_controls_section">
<div className={"window_controls_section " + (isFS === true ? "window_controls_section-hidden" : "")}>
<div className="button_area" id="minimize">
<img className="icon" srcSet={`${min_w_10} 1x, ${min_w_12} 1.25x, ${min_w_15} 1.5x, ${min_w_15} 1.75x,
${min_w_20} 2x, ${min_w_20} 2.25x, ${min_w_24} 2.5x, ${min_w_30} 3x, ${min_w_30} 3.5x`}/>
Expand All @@ -134,7 +137,6 @@ const HeaderWindows: FunctionComponent<HeaderWindowsProps> = (props: HeaderWindo
</div>
</div>
</div>

<div className="button_area" id="close">
<img className="icon" srcSet={`${close_w_10} 1x, ${close_w_12} 1.25x, ${close_w_15} 1.5x, ${close_w_15} 1.75x,
${close_w_20} 2x, ${close_w_20} 2.25x, ${close_w_24} 2.5x, ${close_w_30} 3x, ${close_w_30} 3.5x`}/>
Expand Down
7 changes: 5 additions & 2 deletions muzik-offline/src/interface/layouts/SearchArtists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SearchArtists = () => {

function setMenuOpenData(key: number, n_co_ords: {xPos: number; yPos: number;}){
setCoords(n_co_ords);
const matching_artist = artists.find(artist => { return artist.key === key; })
const matching_artist = artists.find(artist => { return artist.key === key; });
setArtistMenuToOpen(matching_artist ? matching_artist : null);
}

Expand Down Expand Up @@ -47,7 +47,10 @@ const SearchArtists = () => {
}
}

function navigateTo(key: number){ navigate("/ArtistCatalogue/" + artists[key].artist_name); }
function navigateTo(key: number){
const matching_artist = artists.find(artist => { return artist.key === key; });
if(matching_artist !== undefined)navigate("/ArtistCatalogue/" + matching_artist.artist_name);
}

useEffect(() => {
const resetArtists = () => {
Expand Down
17 changes: 15 additions & 2 deletions muzik-offline/src/interface/layouts/SearchPlaylists.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SquareTitleBox, GeneralContextMenu, LoaderAnimated, AddSongsToPlaylistModal, PropertiesModal } from "@components/index";
import { SquareTitleBox, GeneralContextMenu, LoaderAnimated, AddSongsToPlaylistModal, PropertiesModal, DeletePlaylistModal } from "@components/index";
import { playlist, mouse_coOrds, contextMenuEnum, contextMenuButtons } from "@muziktypes/index";
import { useEffect, useState } from "react";
import "@styles/layouts/SearchPlaylists.scss";
Expand All @@ -13,6 +13,7 @@ const SearchPlaylists = () => {
const [isPlaylistModalOpen, setIsPlaylistModalOpen] = useState<boolean>(false);
const [isPropertiesModalOpen, setIsPropertiesModalOpen] = useState<boolean>(false);
const [playlistMenuToOpen, setPlaylistMenuToOpen] = useState<playlist | null>(null);
const [isDeletePlaylistModalOpen, setIsDeletePlaylistModalOpen] = useState<boolean>(false);
const { query } = useSearchStore((state) => { return { query: state.query}; });
const [playlists, setPlaylists] = useState<playlist[]>([]);
const navigate = useNavigate();
Expand All @@ -33,6 +34,7 @@ const SearchPlaylists = () => {
if(arg == contextMenuButtons.ShowPlaylist && playlistMenuToOpen)navigateTo(playlistMenuToOpen.key);
else if(arg === contextMenuButtons.ShowInfo){ setIsPropertiesModalOpen(true); }
else if(arg === contextMenuButtons.AddToPlaylist){ setIsPlaylistModalOpen(true); }
else if(arg === contextMenuButtons.Delete){ setIsDeletePlaylistModalOpen(true); }
else if(arg === contextMenuButtons.PlayNext && playlistMenuToOpen){
addTheseSongsToPlayNext({playlist: playlistMenuToOpen.title});
closeContextMenu();
Expand All @@ -47,6 +49,13 @@ const SearchPlaylists = () => {
}
}

async function shouldDeletePlaylist(deletePlaylist: boolean){
if(deletePlaylist && playlistMenuToOpen)await local_playlists_db.playlists.delete(playlistMenuToOpen.key);
setPlaylistMenuToOpen(null);
setCoords({xPos: 0, yPos: 0});
setIsDeletePlaylistModalOpen(false);
}

function navigateTo(passed_key: number){ navigate(`/PlaylistView/${passed_key}`); }

useEffect(() => {
Expand All @@ -61,7 +70,7 @@ const SearchPlaylists = () => {
}

resetPlaylists();
}, [query])
}, [query, isDeletePlaylistModalOpen])

return (
<div className="SearchPlaylists">
Expand Down Expand Up @@ -108,6 +117,10 @@ const SearchPlaylists = () => {
title={playlistMenuToOpen? playlistMenuToOpen.title : ""}
values={{playlist: playlistMenuToOpen? playlistMenuToOpen.title : ""}}
closeModal={() => setIsPlaylistModalOpen(false)} />
<DeletePlaylistModal
isOpen={isDeletePlaylistModalOpen}
title={playlistMenuToOpen? playlistMenuToOpen.title : ""}
closeModal={shouldDeletePlaylist} />
</div>
)
}
Expand Down
12 changes: 3 additions & 9 deletions muzik-offline/src/interface/pages/AllPlaylists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@ const AllPlaylists = () => {
}

async function shouldDeletePlaylist(deletePlaylist: boolean){
if(deletePlaylist && state.playlistMenuToOpen){
await local_playlists_db.playlists.delete(state.playlistMenuToOpen.key);
dispatch({ type: reducerType.SET_DELETE_MODAL, payload: false});
dispatch({ type: reducerType.SET_PLAYLIST_MENU, payload: null});
}
else{
dispatch({ type: reducerType.SET_DELETE_MODAL, payload: false});
dispatch({ type: reducerType.SET_PLAYLIST_MENU, payload: null});
}
if(deletePlaylist && state.playlistMenuToOpen)await local_playlists_db.playlists.delete(state.playlistMenuToOpen.key);
dispatch({ type: reducerType.SET_DELETE_MODAL, payload: false});
dispatch({ type: reducerType.SET_PLAYLIST_MENU, payload: null});
}

useEffect(() => { setList(); }, [state.sort, state.isCreatePlaylistModalOpen, state.isDeletePlayListModalOpen])
Expand Down
28 changes: 14 additions & 14 deletions muzik-offline/src/interface/pages/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ import { Disk, LayersThree, Menu, Microphone, MusicalNote } from "@assets/icons"
import { SearchNavigator } from "@components/index";
import {SearchAlbums, SearchArtists, SearchGenres, SearchPlaylists, SearchSongs} from "@layouts/index";
import { motion } from "framer-motion";
import { useState } from "react";
import { useNavigate, useLocation } from "react-router-dom";
import "@styles/pages/SearchPage.scss";
import { Route, Routes } from 'react-router-dom';
import { useState } from "react";

const SearchPage = () => {
const [selected, setSelected] = useState<string>("songs");
const navigate = useNavigate();
const location = useLocation();
const [selected, setSelected] = useState<string>(location.pathname.replace("/SearchPage/", ""));

function setSelectedF(arg: string){
setSelected(arg);
navigate(`/SearchPage/${arg}`);
}

return (
Expand All @@ -25,18 +30,13 @@ const SearchPage = () => {
<SearchNavigator icon={Menu} text={"playlists"} selected={selected} select={setSelectedF}/>
</div>
<div className="content-container">
{
selected === "songs" ?
<SearchSongs />
: selected === "artists" ?
<SearchArtists />
: selected === "albums" ?
<SearchAlbums />
: selected === "genres" ?
<SearchGenres />
:
<SearchPlaylists />
}
<Routes>
<Route index path="songs" element={<SearchSongs/>}/>
<Route path="artists" element={<SearchArtists/>}/>
<Route path="albums" element={<SearchAlbums/>}/>
<Route path="genres" element={<SearchGenres/>}/>
<Route path="playlists" element={<SearchPlaylists/>}/>
</Routes>
</div>
</motion.div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

.PlayIcon{
margin-right: 23px;
cursor: default;
svg{
path{
fill: $app-theme-col;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@
#close:active{background: #F1707A;}

}

.window_controls_section-hidden{
display: none;
}
}


Expand Down