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
View File
@@ -10721,11 +10721,6 @@
"resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
"integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=" "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": { "lodash.isequalwith": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.isequalwith/-/lodash.isequalwith-4.4.0.tgz", "resolved": "https://registry.npmjs.org/lodash.isequalwith/-/lodash.isequalwith-4.4.0.tgz",
-1
View File
@@ -11,7 +11,6 @@
"deepmerge": "^4.2.2", "deepmerge": "^4.2.2",
"history": "^4.10.1", "history": "^4.10.1",
"jwt-decode": "^3.1.2", "jwt-decode": "^3.1.2",
"lodash.get": "^4.4.2",
"lodash.pick": "^4.4.0", "lodash.pick": "^4.4.0",
"lodash.throttle": "^4.1.1", "lodash.throttle": "^4.1.1",
"md5-hex": "^3.0.1", "md5-hex": "^3.0.1",
+1 -2
View File
@@ -1,5 +1,4 @@
import React, { memo } from 'react' import React, { memo } from 'react'
import get from 'lodash.get'
import Typography from '@material-ui/core/Typography' import Typography from '@material-ui/core/Typography'
import sanitizeFieldRestProps from './sanitizeFieldRestProps' import sanitizeFieldRestProps from './sanitizeFieldRestProps'
import md5 from 'md5-hex' import md5 from 'md5-hex'
@@ -15,7 +14,7 @@ export const MultiLineTextField = memo(
addLabel, addLabel,
...rest ...rest
}) => { }) => {
const value = get(record, source) const value = record && record[source]
let lines = value ? value.split('\n') : [] let lines = value ? value.split('\n') : []
if (maxLines || firstLine) { if (maxLines || firstLine) {
lines = lines.slice(firstLine, maxLines) lines = lines.slice(firstLine, maxLines)
+1 -2
View File
@@ -3,7 +3,6 @@ import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import { FunctionField } from 'react-admin' import { FunctionField } from 'react-admin'
import get from 'lodash.get'
import { useTheme } from '@material-ui/core/styles' import { useTheme } from '@material-ui/core/styles'
import PlayingLight from '../icons/playing-light.gif' import PlayingLight from '../icons/playing-light.gif'
import PlayingDark from '../icons/playing-dark.gif' import PlayingDark from '../icons/playing-dark.gif'
@@ -28,7 +27,7 @@ export const SongTitleField = ({ showTrackNumbers, ...props }) => {
const theme = useTheme() const theme = useTheme()
const classes = useStyles() const classes = useStyles()
const { record } = props const { record } = props
const currentTrack = useSelector((state) => get(state, 'queue.current', {})) const currentTrack = useSelector((state) => state?.queue?.current || {})
const currentId = currentTrack.trackId const currentId = currentTrack.trackId
const paused = currentTrack.paused const paused = currentTrack.paused
const isCurrent = const isCurrent =
+2 -3
View File
@@ -1,5 +1,4 @@
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import get from 'lodash.get'
const getPerPage = (width) => { const getPerPage = (width) => {
if (width === 'xs') return 12 if (width === 'xs') return 12
@@ -19,8 +18,8 @@ const getPerPageOptions = (width) => {
export const useAlbumsPerPage = (width) => { export const useAlbumsPerPage = (width) => {
const perPage = const perPage =
useSelector((state) => useSelector(
get(state.admin.resources, ['album', 'list', 'params', 'perPage']) (state) => state?.admin.resources?.album?.list?.params?.perPage
) || getPerPage(width) ) || getPerPage(width)
return [perPage, getPerPageOptions(width)] return [perPage, getPerPageOptions(width)]
+1 -2
View File
@@ -1,5 +1,4 @@
import 'react-jinke-music-player/assets/index.css' import 'react-jinke-music-player/assets/index.css'
import get from 'lodash.get'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import subsonic from '../subsonic' import subsonic from '../subsonic'
import config from '../config' import config from '../config'
@@ -85,7 +84,7 @@ export const playQueueReducer = (previousState = initialState, payload) => {
}) })
return { ...previousState, queue, clear: false, playIndex: undefined } return { ...previousState, queue, clear: false, playIndex: undefined }
case PLAYER_PLAY_NEXT: case PLAYER_PLAY_NEXT:
current = get(previousState.current, 'uuid', '') current = previousState.current?.uuid || ''
newQueue = [] newQueue = []
let foundPos = false let foundPos = false
previousState.queue.forEach((item) => { previousState.queue.forEach((item) => {