diff --git a/src/renderer/components/maps-mangement-components/filter-panel.component.tsx b/src/renderer/components/maps-mangement-components/filter-panel.component.tsx index faa7dac9..403c27dc 100644 --- a/src/renderer/components/maps-mangement-components/filter-panel.component.tsx +++ b/src/renderer/components/maps-mangement-components/filter-panel.component.tsx @@ -81,28 +81,26 @@ export function FilterPanel({className, ref, playlist = false, filter, onChange} } const handleTagClick = (tag: MapTag) => { - if(filter.enabledTags.has(tag)){ - filter.enabledTags.delete(tag); - filter.excludedTags.add(tag); - return onChange({ - ...filter, - enabledTags: filter.enabledTags, - excludedTags: filter.excludedTags - }) + + const enabledTags = filter.enabledTags ?? new Set(); + const excludedTags = filter.excludedTags ?? new Set(); + + if(isTagExcluded(tag)){ + excludedTags.delete(tag); } - if(filter.excludedTags.has(tag)){ - filter.excludedTags.delete(tag); - return onChange({ - ...filter, - excludedTags: filter.excludedTags - }) + else if(isTagActivated(tag)){ + excludedTags.add(tag); + enabledTags.delete(tag); + } + else{ + enabledTags.add(tag); } - filter.enabledTags.add(tag); onChange({ ...filter, - enabledTags: filter.enabledTags - }) + enabledTags, + excludedTags + }); } @@ -171,12 +169,12 @@ export function FilterPanel({className, ref, playlist = false, filter, onChange}

TAGS

{MAP_TYPES.map(tag => ( - handleTagClick(tag)} className={`text-[12.5px] text-black rounded-md px-1 font-bold cursor-pointer ${(!isTagActivated(tag)) && "opacity-40 hover:opacity-100"}`} style={{backgroundColor: isTagExcluded(tag) ? diffColors.Expert : diffColors.Normal}}>{tag} + handleTagClick(tag)} className={`text-[12.5px] text-black rounded-md px-1 font-bold cursor-pointer ${(!isTagActivated(tag)) && "opacity-40 hover:opacity-90"}`} style={{backgroundColor: isTagExcluded(tag) ? diffColors.Expert : diffColors.Normal}}>{tag} ))}
{MAP_STYLES.map(tag => ( - handleTagClick(tag)} className={`text-[12.5px] text-black rounded-md px-1 font-bold cursor-pointer ${(!isTagActivated(tag)) && "opacity-40 hover:opacity-100"}`} style={{backgroundColor: isTagExcluded(tag) ? diffColors.Expert : diffColors.Easy}}>{tag} + handleTagClick(tag)} className={`text-[12.5px] text-black rounded-md px-1 font-bold cursor-pointer ${(!isTagActivated(tag)) && "opacity-40 hover:opacity-90"}`} style={{backgroundColor: isTagExcluded(tag) ? diffColors.Expert : diffColors.Easy}}>{tag} ))}
diff --git a/src/renderer/components/maps-mangement-components/maps-playlists-panel.component.tsx b/src/renderer/components/maps-mangement-components/maps-playlists-panel.component.tsx index 1e729a8b..ff1f593a 100644 --- a/src/renderer/components/maps-mangement-components/maps-playlists-panel.component.tsx +++ b/src/renderer/components/maps-mangement-components/maps-playlists-panel.component.tsx @@ -1,18 +1,16 @@ -import { createRef, DetailedHTMLProps, useEffect, useRef, useState } from "react" +import { DetailedHTMLProps, useEffect, useRef, useState } from "react" import { BSVersion } from "shared/bs-version.interface" import { TabNavBar } from "../shared/tab-nav-bar.component" import { LocalMapsListPanel } from "./local-maps-list-panel.component" import { BsmDropdownButton, DropDownItem } from "../shared/bsm-dropdown-button.component" import { FilterPanel } from "./filter-panel.component" -import { MapFilter, MapTag } from "shared/models/maps/beat-saver.model" +import { MapFilter } from "shared/models/maps/beat-saver.model" import { BsmButton } from "../shared/bsm-button.component" import { useThemeColor } from "renderer/hooks/use-theme-color.hook" import { MapsManagerService } from "renderer/services/maps-manager.service" import { motion, Variants } from "framer-motion"; import ReactTooltip from 'react-tooltip'; import { MapsDownloaderService } from "renderer/services/maps-downloader.service" -import { BehaviorSubject } from "rxjs" -import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface" type Props = { version?: BSVersion @@ -22,13 +20,9 @@ export function MapsPlaylistsPanel({version}: Props) { const mapsService = MapsManagerService.getInstance(); const mapsDownloader = MapsDownloaderService.getInstance(); - const mapsManager = MapsManagerService.getInstance(); const [tabIndex, setTabIndex] = useState(0); - const [mapFilter, setMapFilter] = useState({ - enabledTags: new Set(), - excludedTags: new Set() - }); + const [mapFilter, setMapFilter] = useState({}); const [mapSearch, setMapSearch] = useState(""); const [playlistSearch, setPlaylistSearch] = useState(""); const [mapsLinked, setMapsLinked] = useState(false); @@ -64,7 +58,8 @@ export function MapsPlaylistsPanel({version}: Props) { const renderTab = (props: DetailedHTMLProps, HTMLLIElement>, text: string, index: number): JSX.Element => { - const mainColor = mapsLinked ? color : "red"; + const linkedColor = mapsLinked ? color : "red"; + const addMapColor = color; const onClickLink = (index: number) => { if(index === 0){ handleMapsLinkClick(); } @@ -77,19 +72,27 @@ export function MapsPlaylistsPanel({version}: Props) { const variants: Variants = { hover: {rotate: 22.5}, tap: {rotate: 45} }; return ( -
  • +
  • {text} - - - {e.stopPropagation(); onClickLink(index)}}/> - - - - {e.stopPropagation(); onClickAdd(index)}}/> - - - Ajouté des maps {/* TODO TRANSLATE */} - +
    + + + + {e.stopPropagation(); onClickAdd(index)}}/> + + + Ajouté des maps {/* TODO TRANSLATE */} + + {!!version && ( + + + {e.stopPropagation(); onClickLink(index)}}/> + + )} +
    + + +
  • ) }