mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
enable tidal search
This commit is contained in:
parent
0db4e57f02
commit
d344653e57
@ -10,6 +10,8 @@ import { WithPlayerContext } from "contexts/WithPlayerContext"
|
|||||||
|
|
||||||
import FeedModel from "models/feed"
|
import FeedModel from "models/feed"
|
||||||
import PlaylistModel from "models/playlists"
|
import PlaylistModel from "models/playlists"
|
||||||
|
import MusicModel from "models/music"
|
||||||
|
import SyncModel from "models/sync"
|
||||||
|
|
||||||
import MusicTrack from "components/Music/Track"
|
import MusicTrack from "components/Music/Track"
|
||||||
import PlaylistItem from "components/Music/PlaylistItem"
|
import PlaylistItem from "components/Music/PlaylistItem"
|
||||||
@ -17,11 +19,33 @@ import PlaylistItem from "components/Music/PlaylistItem"
|
|||||||
import "./index.less"
|
import "./index.less"
|
||||||
|
|
||||||
const MusicNavbar = (props) => {
|
const MusicNavbar = (props) => {
|
||||||
|
const [loading, setLoading] = React.useState(true)
|
||||||
|
const [hasTidal, setHasTidal] = React.useState(false)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
SyncModel.hasServiceLinked("tidal")
|
||||||
|
.catch(() => {
|
||||||
|
setHasTidal(false)
|
||||||
|
setLoading(false)
|
||||||
|
})
|
||||||
|
.then((value) => {
|
||||||
|
setHasTidal(value.active)
|
||||||
|
setLoading(false)
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return <div className="music_navbar">
|
return <div className="music_navbar">
|
||||||
<Searcher
|
<Searcher
|
||||||
useUrlQuery
|
useUrlQuery
|
||||||
renderResults={false}
|
renderResults={false}
|
||||||
model={PlaylistModel.search}
|
model={MusicModel.search}
|
||||||
|
modelParams={{
|
||||||
|
useTidal: hasTidal,
|
||||||
|
}}
|
||||||
onSearchResult={props.setSearchResults}
|
onSearchResult={props.setSearchResults}
|
||||||
onEmpty={() => props.setSearchResults(false)}
|
onEmpty={() => props.setSearchResults(false)}
|
||||||
/>
|
/>
|
||||||
@ -243,16 +267,28 @@ const SearchResults = ({
|
|||||||
|
|
||||||
export default (props) => {
|
export default (props) => {
|
||||||
const [searchResults, setSearchResults] = React.useState(false)
|
const [searchResults, setSearchResults] = React.useState(false)
|
||||||
|
const [loading, setLoading] = React.useState(true)
|
||||||
|
const [hasTidal, setHasTidal] = React.useState(false)
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
app.layout.toggleCenteredContent(true)
|
app.layout.toggleCenteredContent(true)
|
||||||
|
|
||||||
app.layout.page_panels.attachComponent("music_navbar", MusicNavbar, {
|
app.layout.page_panels.attachComponent("music_navbar", MusicNavbar, {
|
||||||
props: {
|
props: {
|
||||||
setSearchResults: setSearchResults
|
setSearchResults: setSearchResults,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
SyncModel.hasServiceLinked("tidal")
|
||||||
|
.catch(() => {
|
||||||
|
setHasTidal(false)
|
||||||
|
setLoading(false)
|
||||||
|
})
|
||||||
|
.then((value) => {
|
||||||
|
setHasTidal(value.active)
|
||||||
|
setLoading(false)
|
||||||
|
})
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (app.layout.page_panels) {
|
if (app.layout.page_panels) {
|
||||||
app.layout.page_panels.detachComponent("music_navbar")
|
app.layout.page_panels.detachComponent("music_navbar")
|
||||||
@ -260,6 +296,10 @@ export default (props) => {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return <div
|
return <div
|
||||||
className={classnames(
|
className={classnames(
|
||||||
"musicExplorer",
|
"musicExplorer",
|
||||||
@ -269,7 +309,10 @@ export default (props) => {
|
|||||||
app.isMobile && <Searcher
|
app.isMobile && <Searcher
|
||||||
useUrlQuery
|
useUrlQuery
|
||||||
renderResults={false}
|
renderResults={false}
|
||||||
model={PlaylistModel.search}
|
model={MusicModel.search}
|
||||||
|
modelParams={{
|
||||||
|
useTidal: hasTidal,
|
||||||
|
}}
|
||||||
onSearchResult={setSearchResults}
|
onSearchResult={setSearchResults}
|
||||||
onEmpty={() => setSearchResults(false)}
|
onEmpty={() => setSearchResults(false)}
|
||||||
/>
|
/>
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
padding: 20px;
|
|
||||||
|
|
||||||
background-color: var(--background-color-accent);
|
background-color: var(--background-color-accent);
|
||||||
|
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user