mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
don't reset parts manually, do it all at once
This commit is contained in:
@@ -6,7 +6,7 @@ import NothingHere from '@app/components/NothingHere'
|
||||
import { useFetchPaginatedList } from '@app/hooks/list'
|
||||
import { useActiveServerRefresh } from '@app/hooks/server'
|
||||
import { AlbumListItem } from '@app/models/music'
|
||||
import { Album } from '@app/state/library'
|
||||
import { Album, mapById } from '@app/state/library'
|
||||
import { selectMusic } from '@app/state/music'
|
||||
import { selectSettings } from '@app/state/settings'
|
||||
import { Store, useStore } from '@app/state/store'
|
||||
@@ -56,7 +56,7 @@ const Category = React.memo<{
|
||||
type: string
|
||||
}>(({ type }) => {
|
||||
const list = useHomeStore(useCallback(store => store.lists[type] || [], [type]))
|
||||
const albums = useStore(useCallback(store => list.map(id => store.entities.albums[id]), [list]))
|
||||
const albums = useStore(useCallback(store => mapById(store.entities.albums, list), [list]))
|
||||
|
||||
const Albums = () => (
|
||||
<ScrollView
|
||||
|
||||
@@ -4,6 +4,7 @@ import FilterButton, { OptionData } from '@app/components/FilterButton'
|
||||
import GradientFlatList from '@app/components/GradientFlatList'
|
||||
import { useFetchPaginatedList } from '@app/hooks/list'
|
||||
import { Album, AlbumListItem } from '@app/models/music'
|
||||
import { mapById } from '@app/state/library'
|
||||
import { selectSettings } from '@app/state/settings'
|
||||
import { Store, useStore } from '@app/state/store'
|
||||
import colors from '@app/styles/colors'
|
||||
@@ -96,7 +97,7 @@ const AlbumsList = () => {
|
||||
)
|
||||
|
||||
const { list, refreshing, refresh, fetchNextPage } = useFetchPaginatedList(fetchPage, 300)
|
||||
const albums = useStore(useCallback(store => list.map(id => store.entities.albums[id]), [list]))
|
||||
const albums = useStore(useCallback(store => mapById(store.entities.albums, list), [list]))
|
||||
|
||||
const layout = useWindowDimensions()
|
||||
|
||||
|
||||
@@ -23,9 +23,7 @@ const selectArtists = (store: Store) => store.entities.artists
|
||||
|
||||
const ArtistsList = () => {
|
||||
const fetchArtists = useStore(store => store.fetchLibraryArtists)
|
||||
const resetArtists = useStore(store => store.resetLibraryArtists)
|
||||
|
||||
const { refreshing, refresh } = useFetchList2(fetchArtists, resetArtists)
|
||||
const { refreshing, refresh } = useFetchList2(fetchArtists)
|
||||
const artists = useStore(selectArtists)
|
||||
|
||||
const filter = useStore(selectSettings.libraryArtistFilter)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import GradientFlatList from '@app/components/GradientFlatList'
|
||||
import ListItem from '@app/components/ListItem'
|
||||
import { useFetchList } from '@app/hooks/list'
|
||||
import { useFetchList, useFetchList2 } from '@app/hooks/list'
|
||||
import { PlaylistListItem } from '@app/models/music'
|
||||
import { selectMusic } from '@app/state/music'
|
||||
import { useStore } from '@app/state/store'
|
||||
import React from 'react'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import { StyleSheet } from 'react-native'
|
||||
|
||||
const PlaylistRenderItem: React.FC<{ item: PlaylistListItem }> = ({ item }) => (
|
||||
@@ -12,12 +12,13 @@ const PlaylistRenderItem: React.FC<{ item: PlaylistListItem }> = ({ item }) => (
|
||||
)
|
||||
|
||||
const PlaylistsList = () => {
|
||||
const fetchPlaylists = useStore(selectMusic.fetchPlaylists)
|
||||
const { list, refreshing, refresh } = useFetchList(fetchPlaylists)
|
||||
const fetchPlaylists = useStore(store => store.fetchLibraryPlaylists)
|
||||
const { refreshing, refresh } = useFetchList2(fetchPlaylists)
|
||||
const playlists = useStore(store => store.entities.playlists)
|
||||
|
||||
return (
|
||||
<GradientFlatList
|
||||
data={list}
|
||||
data={Object.values(playlists)}
|
||||
renderItem={PlaylistRenderItem}
|
||||
keyExtractor={item => item.id}
|
||||
onRefresh={refresh}
|
||||
|
||||
Reference in New Issue
Block a user