chore: upgrade all dependencies
This commit is contained in:
@@ -1,23 +1,21 @@
|
||||
import { createAction, createAsyncThunk, createEntityAdapter, EntityId } from '@reduxjs/toolkit';
|
||||
import { createAction, createAsyncThunk, createEntityAdapter } from '@reduxjs/toolkit';
|
||||
import { AppState } from '@/store';
|
||||
import { generateTrackUrl } from '@/utility/JellyfinApi';
|
||||
import { downloadFile, unlink, DocumentDirectoryPath, exists } from 'react-native-fs';
|
||||
import { DownloadEntity } from './types';
|
||||
import MimeTypes from '@/utility/MimeTypes';
|
||||
|
||||
export const downloadAdapter = createEntityAdapter<DownloadEntity>({
|
||||
selectId: (entity) => entity.id,
|
||||
});
|
||||
export const downloadAdapter = createEntityAdapter<DownloadEntity>();
|
||||
|
||||
export const queueTrackForDownload = createAction<EntityId>('download/queue');
|
||||
export const initializeDownload = createAction<{ id: EntityId, size?: number, jobId?: number, location: string }>('download/initialize');
|
||||
export const progressDownload = createAction<{ id: EntityId, progress: number, jobId?: number }>('download/progress');
|
||||
export const completeDownload = createAction<{ id: EntityId, location: string, size?: number }>('download/complete');
|
||||
export const failDownload = createAction<{ id: EntityId }>('download/fail');
|
||||
export const queueTrackForDownload = createAction<string>('download/queue');
|
||||
export const initializeDownload = createAction<{ id: string, size?: number, jobId?: number, location: string }>('download/initialize');
|
||||
export const progressDownload = createAction<{ id: string, progress: number, jobId?: number }>('download/progress');
|
||||
export const completeDownload = createAction<{ id: string, location: string, size?: number }>('download/complete');
|
||||
export const failDownload = createAction<{ id: string }>('download/fail');
|
||||
|
||||
export const downloadTrack = createAsyncThunk(
|
||||
'/downloads/track',
|
||||
async (id: EntityId, { dispatch, getState }) => {
|
||||
async (id: string, { dispatch, getState }) => {
|
||||
// Get the credentials from the store
|
||||
const { settings: { jellyfin: credentials } } = (getState() as AppState);
|
||||
|
||||
@@ -63,7 +61,7 @@ export const downloadTrack = createAsyncThunk(
|
||||
|
||||
export const removeDownloadedTrack = createAsyncThunk(
|
||||
'/downloads/remove/track',
|
||||
async(id: EntityId, { getState }) => {
|
||||
async(id: string, { getState }) => {
|
||||
// Retrieve the state
|
||||
const { downloads: { entities }} = getState() as AppState;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createSlice, Dictionary, EntityId } from '@reduxjs/toolkit';
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import {
|
||||
completeDownload,
|
||||
downloadAdapter,
|
||||
@@ -12,9 +12,9 @@ import {
|
||||
import { DownloadEntity } from './types';
|
||||
|
||||
interface State {
|
||||
entities: Dictionary<DownloadEntity>;
|
||||
ids: EntityId[];
|
||||
queued: EntityId[];
|
||||
entities: Record<string, DownloadEntity>;
|
||||
ids: string[];
|
||||
queued: string[];
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createSelector, EntityId } from '@reduxjs/toolkit';
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { intersection } from 'lodash';
|
||||
import { AppState } from '@/store';
|
||||
|
||||
@@ -8,7 +8,7 @@ export const selectDownloadedEntities = (state: AppState) => state.downloads.ent
|
||||
/**
|
||||
* Only retain the supplied trackIds that have successfully been downloaded
|
||||
*/
|
||||
export const selectDownloadedTracks = (trackIds: EntityId[]) => (
|
||||
export const selectDownloadedTracks = (trackIds: string[]) => (
|
||||
createSelector(
|
||||
selectAllDownloads,
|
||||
({ entities, ids }) => {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { EntityId } from '@reduxjs/toolkit';
|
||||
|
||||
export interface DownloadEntity {
|
||||
id: EntityId;
|
||||
id: string;
|
||||
progress: number;
|
||||
isFailed: boolean;
|
||||
isComplete: boolean;
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { configureStore, getDefaultMiddleware, combineReducers } from '@reduxjs/toolkit';
|
||||
import { configureStore, combineReducers } from '@reduxjs/toolkit';
|
||||
import { useSelector, TypedUseSelectorHook, useDispatch } from 'react-redux';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { persistStore, persistReducer, PersistConfig, createMigrate } from 'redux-persist';
|
||||
import { persistStore, persistReducer, PersistConfig, createMigrate, PersistState } from 'redux-persist';
|
||||
import autoMergeLevel2 from 'redux-persist/es/stateReconciler/autoMergeLevel2';
|
||||
|
||||
import settings from './settings';
|
||||
import music, { initialState as musicInitialState } from './music';
|
||||
import downloads, { initialState as downloadsInitialState } from './downloads';
|
||||
import { PersistState } from 'redux-persist/es/types';
|
||||
import { ColorScheme } from './settings/types';
|
||||
import sleepTimer from './sleep-timer';
|
||||
import { ColorScheme } from './settings/types';
|
||||
|
||||
const persistConfig: PersistConfig<Omit<AppState, '_persist'>> = {
|
||||
key: 'root',
|
||||
@@ -77,16 +76,11 @@ const reducers = combineReducers({
|
||||
|
||||
const persistedReducer = persistReducer(persistConfig, reducers);
|
||||
|
||||
const middlewares = [];
|
||||
if (__DEV__) {
|
||||
middlewares.push(require('redux-flipper').default());
|
||||
}
|
||||
|
||||
const store = configureStore({
|
||||
reducer: persistedReducer,
|
||||
middleware: getDefaultMiddleware({ serializableCheck: false, immutableCheck: false }).concat(
|
||||
// logger,
|
||||
...middlewares,
|
||||
middleware: (getDefaultMiddleware) => (
|
||||
getDefaultMiddleware({ serializableCheck: false, immutableCheck: false })
|
||||
.concat(__DEV__ ? [require('redux-flipper').default()] : [])
|
||||
),
|
||||
});
|
||||
|
||||
@@ -94,7 +88,7 @@ export type AppState = ReturnType<typeof reducers> & { _persist: PersistState };
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
export type AsyncThunkAPI = { state: AppState, dispatch: AppDispatch };
|
||||
export const useTypedSelector: TypedUseSelectorHook<AppState> = useSelector;
|
||||
export const useAppDispatch = () => useDispatch<AppDispatch>();
|
||||
export const useAppDispatch: () => AppDispatch = useDispatch;
|
||||
|
||||
export const persistedStore = persistStore(store);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Album, AlbumTrack, Playlist } from './types';
|
||||
import { AsyncThunkAPI } from '..';
|
||||
import { retrieveAllAlbums, retrieveAlbumTracks, retrieveRecentAlbums, searchItem, retrieveAlbum, retrieveAllPlaylists, retrievePlaylistTracks } from '@/utility/JellyfinApi';
|
||||
|
||||
export const albumAdapter = createEntityAdapter<Album>({
|
||||
export const albumAdapter = createEntityAdapter<Album, string>({
|
||||
selectId: album => album.Id,
|
||||
sortComparer: (a, b) => a.Name.localeCompare(b.Name),
|
||||
});
|
||||
@@ -30,7 +30,7 @@ export const fetchRecentAlbums = createAsyncThunk<Album[], number | undefined, A
|
||||
}
|
||||
);
|
||||
|
||||
export const trackAdapter = createEntityAdapter<AlbumTrack>({
|
||||
export const trackAdapter = createEntityAdapter<AlbumTrack, string>({
|
||||
selectId: track => track.Id,
|
||||
sortComparer: (a, b) => a.IndexNumber - b.IndexNumber,
|
||||
});
|
||||
@@ -86,7 +86,7 @@ AsyncThunkAPI
|
||||
}
|
||||
);
|
||||
|
||||
export const playlistAdapter = createEntityAdapter<Playlist>({
|
||||
export const playlistAdapter = createEntityAdapter<Playlist, string>({
|
||||
selectId: (playlist) => playlist.Id,
|
||||
sortComparer: (a, b) => a.Name.localeCompare(b.Name),
|
||||
});
|
||||
|
||||
@@ -10,28 +10,28 @@ import {
|
||||
fetchTracksByPlaylist,
|
||||
fetchAlbum
|
||||
} from './actions';
|
||||
import { createSlice, Dictionary, EntityId } from '@reduxjs/toolkit';
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import { Album, AlbumTrack, Playlist } from './types';
|
||||
import { setJellyfinCredentials } from '@/store/settings/actions';
|
||||
|
||||
export interface State {
|
||||
albums: {
|
||||
isLoading: boolean;
|
||||
entities: Dictionary<Album>;
|
||||
ids: EntityId[];
|
||||
entities: Record<string, Album>;
|
||||
ids: string[];
|
||||
lastRefreshed?: number,
|
||||
},
|
||||
tracks: {
|
||||
isLoading: boolean;
|
||||
entities: Dictionary<AlbumTrack>;
|
||||
ids: EntityId[];
|
||||
byAlbum: Dictionary<EntityId[]>;
|
||||
byPlaylist: Dictionary<EntityId[]>;
|
||||
entities: Record<string, AlbumTrack>;
|
||||
ids: string[];
|
||||
byAlbum: Record<string, string[]>;
|
||||
byPlaylist: Record<string, string[]>;
|
||||
},
|
||||
playlists: {
|
||||
isLoading: boolean;
|
||||
entities: Dictionary<Playlist>;
|
||||
ids: EntityId[];
|
||||
entities: Record<string, Playlist>;
|
||||
ids: string[];
|
||||
lastRefreshed?: number,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useTypedSelector, AppState } from '@/store';
|
||||
import { parseISO } from 'date-fns';
|
||||
import { ALPHABET_LETTERS } from '@/CONSTANTS';
|
||||
import { createSelector, EntityId } from '@reduxjs/toolkit';
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { SectionListData } from 'react-native';
|
||||
import { ArtistItem } from './types';
|
||||
|
||||
@@ -51,7 +51,7 @@ export const selectAlbumsByArtist = createSelector(
|
||||
albumsByArtist,
|
||||
);
|
||||
|
||||
export type SectionedId = SectionListData<EntityId[]>;
|
||||
export type SectionedId = SectionListData<string[]>;
|
||||
|
||||
/**
|
||||
* Splits a set of albums into a list that is split by alphabet letters
|
||||
@@ -77,7 +77,7 @@ function splitAlbumsByAlphabet(state: AppState['music']['albums']): SectionedId[
|
||||
|
||||
// GUARD: Check if the row is overflowing. If so, add a new row.
|
||||
if (section.data[row].length >= 2) {
|
||||
(section.data as EntityId[][]).push([]);
|
||||
(section.data as string[][]).push([]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -92,7 +92,7 @@ export const selectAlbumsByAlphabet = createSelector(
|
||||
splitAlbumsByAlphabet,
|
||||
);
|
||||
|
||||
export type SectionArtistItem = ArtistItem & { albumIds: EntityId[] };
|
||||
export type SectionArtistItem = ArtistItem & { albumIds: string[] };
|
||||
|
||||
/**
|
||||
* Retrieve all artists based on the available albums
|
||||
@@ -107,7 +107,7 @@ export function artistsFromAlbums(state: AppState['music']['albums']) {
|
||||
album?.ArtistItems.forEach((artist) => {
|
||||
// GUARD: Check that an array already exists for this artist
|
||||
if (!(artist.Name in sum)) {
|
||||
sum[artist.Name] = { albumIds: [] as EntityId[], ...artist };
|
||||
sum[artist.Name] = { albumIds: [] as string[], ...artist };
|
||||
}
|
||||
|
||||
// Add the album id to the artist in the object
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { Dictionary } from '@reduxjs/toolkit';
|
||||
|
||||
export interface UserData {
|
||||
PlaybackPositionTicks: number;
|
||||
PlayCount: number;
|
||||
@@ -73,7 +71,7 @@ export interface AlbumTrack {
|
||||
export interface State {
|
||||
albums: {
|
||||
ids: string[];
|
||||
entities: Dictionary<Album>;
|
||||
entities: Record<string, Album>;
|
||||
isLoading: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user