Remove dependency on lodash.get

This commit is contained in:
Deluan 2021-05-11 22:08:07 -04:00
parent 978933aa48
commit 4699902369
6 changed files with 5 additions and 15 deletions

5
ui/package-lock.json generated
View File

@ -10721,11 +10721,6 @@
"resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
"integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0="
},
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
},
"lodash.isequalwith": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.isequalwith/-/lodash.isequalwith-4.4.0.tgz",

View File

@ -11,7 +11,6 @@
"deepmerge": "^4.2.2",
"history": "^4.10.1",
"jwt-decode": "^3.1.2",
"lodash.get": "^4.4.2",
"lodash.pick": "^4.4.0",
"lodash.throttle": "^4.1.1",
"md5-hex": "^3.0.1",

View File

@ -1,5 +1,4 @@
import React, { memo } from 'react'
import get from 'lodash.get'
import Typography from '@material-ui/core/Typography'
import sanitizeFieldRestProps from './sanitizeFieldRestProps'
import md5 from 'md5-hex'
@ -15,7 +14,7 @@ export const MultiLineTextField = memo(
addLabel,
...rest
}) => {
const value = get(record, source)
const value = record && record[source]
let lines = value ? value.split('\n') : []
if (maxLines || firstLine) {
lines = lines.slice(firstLine, maxLines)

View File

@ -3,7 +3,6 @@ import React from 'react'
import PropTypes from 'prop-types'
import { useSelector } from 'react-redux'
import { FunctionField } from 'react-admin'
import get from 'lodash.get'
import { useTheme } from '@material-ui/core/styles'
import PlayingLight from '../icons/playing-light.gif'
import PlayingDark from '../icons/playing-dark.gif'
@ -28,7 +27,7 @@ export const SongTitleField = ({ showTrackNumbers, ...props }) => {
const theme = useTheme()
const classes = useStyles()
const { record } = props
const currentTrack = useSelector((state) => get(state, 'queue.current', {}))
const currentTrack = useSelector((state) => state?.queue?.current || {})
const currentId = currentTrack.trackId
const paused = currentTrack.paused
const isCurrent =

View File

@ -1,5 +1,4 @@
import { useSelector } from 'react-redux'
import get from 'lodash.get'
const getPerPage = (width) => {
if (width === 'xs') return 12
@ -19,8 +18,8 @@ const getPerPageOptions = (width) => {
export const useAlbumsPerPage = (width) => {
const perPage =
useSelector((state) =>
get(state.admin.resources, ['album', 'list', 'params', 'perPage'])
useSelector(
(state) => state?.admin.resources?.album?.list?.params?.perPage
) || getPerPage(width)
return [perPage, getPerPageOptions(width)]

View File

@ -1,5 +1,4 @@
import 'react-jinke-music-player/assets/index.css'
import get from 'lodash.get'
import { v4 as uuidv4 } from 'uuid'
import subsonic from '../subsonic'
import config from '../config'
@ -85,7 +84,7 @@ export const playQueueReducer = (previousState = initialState, payload) => {
})
return { ...previousState, queue, clear: false, playIndex: undefined }
case PLAYER_PLAY_NEXT:
current = get(previousState.current, 'uuid', '')
current = previousState.current?.uuid || ''
newQueue = []
let foundPos = false
previousState.queue.forEach((item) => {