mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
fixed changing activeServer
This commit is contained in:
@@ -5,7 +5,8 @@ import NothingHere from '@app/components/NothingHere'
|
||||
import PressableOpacity from '@app/components/PressableOpacity'
|
||||
import { AlbumListItem } from '@app/models/music'
|
||||
import { homeListsAtom, homeListsUpdatingAtom, useUpdateHomeLists } from '@app/state/music'
|
||||
import { homeListTypesAtom, useActiveServerRefresh } from '@app/state/settings'
|
||||
import { useActiveServerRefresh } from '@app/state/server'
|
||||
import { homeListTypesAtom } from '@app/state/settings'
|
||||
import colors from '@app/styles/colors'
|
||||
import font from '@app/styles/font'
|
||||
import { GetAlbumListType } from '@app/subsonic/params'
|
||||
|
||||
@@ -3,12 +3,12 @@ import GradientFlatList from '@app/components/GradientFlatList'
|
||||
import PressableOpacity from '@app/components/PressableOpacity'
|
||||
import { Album } from '@app/models/music'
|
||||
import { albumListAtom, albumListUpdatingAtom, useUpdateAlbumList } from '@app/state/music'
|
||||
import { useActiveServerRefresh } from '@app/state/settings'
|
||||
import { useActiveListRefresh } from '@app/state/server'
|
||||
import colors from '@app/styles/colors'
|
||||
import font from '@app/styles/font'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { useAtomValue } from 'jotai/utils'
|
||||
import React, { useEffect } from 'react'
|
||||
import React from 'react'
|
||||
import { StyleSheet, Text, useWindowDimensions, View } from 'react-native'
|
||||
|
||||
const AlbumItem = React.memo<{
|
||||
@@ -56,7 +56,7 @@ const AlbumsList = () => {
|
||||
const updating = useAtomValue(albumListUpdatingAtom)
|
||||
const updateList = useUpdateAlbumList()
|
||||
|
||||
useActiveServerRefresh(updateList)
|
||||
useActiveListRefresh(list, updateList)
|
||||
|
||||
const layout = useWindowDimensions()
|
||||
|
||||
@@ -65,12 +65,6 @@ const AlbumsList = () => {
|
||||
|
||||
const albumsList = list.map(album => ({ album, size, height }))
|
||||
|
||||
useEffect(() => {
|
||||
if (albumsList.length === 0) {
|
||||
updateList()
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<GradientFlatList
|
||||
|
||||
@@ -2,8 +2,9 @@ import GradientFlatList from '@app/components/GradientFlatList'
|
||||
import ListItem from '@app/components/ListItem'
|
||||
import { Artist } from '@app/models/music'
|
||||
import { artistsAtom, artistsUpdatingAtom, useUpdateArtists } from '@app/state/music'
|
||||
import { useActiveListRefresh } from '@app/state/server'
|
||||
import { useAtomValue } from 'jotai/utils'
|
||||
import React, { useEffect } from 'react'
|
||||
import React from 'react'
|
||||
import { StyleSheet } from 'react-native'
|
||||
|
||||
const ArtistRenderItem: React.FC<{ item: Artist }> = ({ item }) => (
|
||||
@@ -15,11 +16,7 @@ const ArtistsList = () => {
|
||||
const updating = useAtomValue(artistsUpdatingAtom)
|
||||
const updateArtists = useUpdateArtists()
|
||||
|
||||
useEffect(() => {
|
||||
if (artists.length === 0) {
|
||||
updateArtists()
|
||||
}
|
||||
})
|
||||
useActiveListRefresh(artists, updateArtists)
|
||||
|
||||
return (
|
||||
<GradientFlatList
|
||||
|
||||
@@ -2,8 +2,9 @@ import GradientFlatList from '@app/components/GradientFlatList'
|
||||
import ListItem from '@app/components/ListItem'
|
||||
import { PlaylistListItem } from '@app/models/music'
|
||||
import { playlistsAtom, playlistsUpdatingAtom, useUpdatePlaylists } from '@app/state/music'
|
||||
import { useActiveListRefresh } from '@app/state/server'
|
||||
import { useAtomValue } from 'jotai/utils'
|
||||
import React, { useEffect } from 'react'
|
||||
import React from 'react'
|
||||
import { StyleSheet } from 'react-native'
|
||||
|
||||
const PlaylistRenderItem: React.FC<{ item: PlaylistListItem }> = ({ item }) => (
|
||||
@@ -15,11 +16,7 @@ const PlaylistsList = () => {
|
||||
const updating = useAtomValue(playlistsUpdatingAtom)
|
||||
const updatePlaylists = useUpdatePlaylists()
|
||||
|
||||
useEffect(() => {
|
||||
if (playlists.length === 0) {
|
||||
updatePlaylists()
|
||||
}
|
||||
})
|
||||
useActiveListRefresh(playlists, updatePlaylists)
|
||||
|
||||
return (
|
||||
<GradientFlatList
|
||||
|
||||
@@ -4,10 +4,10 @@ import Header from '@app/components/Header'
|
||||
import PressableOpacity from '@app/components/PressableOpacity'
|
||||
import SettingsItem from '@app/components/SettingsItem'
|
||||
import { Server } from '@app/models/settings'
|
||||
import { useSetActiveServer } from '@app/state/server'
|
||||
import { activeServerAtom, appSettingsAtom } from '@app/state/settings'
|
||||
import colors from '@app/styles/colors'
|
||||
import { useNavigation } from '@react-navigation/core'
|
||||
import { useAtom } from 'jotai'
|
||||
import { useAtomValue } from 'jotai/utils'
|
||||
import React, { useCallback } from 'react'
|
||||
import { StatusBar, StyleSheet, View } from 'react-native'
|
||||
@@ -16,15 +16,13 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
|
||||
const ServerItem = React.memo<{
|
||||
server: Server
|
||||
}>(({ server }) => {
|
||||
const [activeServer, setActiveServer] = useAtom(activeServerAtom)
|
||||
const activeServer = useAtomValue(activeServerAtom)
|
||||
const setActiveServer = useSetActiveServer()
|
||||
const navigation = useNavigation()
|
||||
|
||||
const setActive = useCallback(() => {
|
||||
if (activeServer?.id === server.id) {
|
||||
return
|
||||
}
|
||||
setActiveServer(server.id)
|
||||
}, [activeServer?.id, server.id, setActiveServer])
|
||||
}, [server.id, setActiveServer])
|
||||
|
||||
return (
|
||||
<SettingsItem
|
||||
|
||||
Reference in New Issue
Block a user