diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx
index cf5e2878..a13cd63e 100644
--- a/src/components/layout/Sidebar.tsx
+++ b/src/components/layout/Sidebar.tsx
@@ -1,9 +1,6 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
-import { useQuery } from 'react-query';
import settings from 'electron-settings';
-import { FixedSizeList as List } from 'react-window';
import useMeasure from 'react-use/lib/useMeasure';
-import { AutoSizer } from 'react-virtualized';
import { LazyLoadImage } from 'react-lazy-load-image-component';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
@@ -18,27 +15,10 @@ import {
SidebarNavItem,
} from './styled';
import { setSidebar } from '../../redux/miscSlice';
-import { apiController } from '../../api/controller';
import { StyledButton } from '../shared/styled';
import { InfoModal } from '../modal/PageModal';
import placeholderImg from '../../img/placeholder.png';
-
-const PlaylistRow = ({ data, index, style }: any) => {
- const history = useHistory();
-
- return (
-
- history.push(`/playlist/${data[index].id}`)}
- >
- {data[index].title}
-
-
- );
-};
+import SidebarPlaylists from './SidebarPlaylists';
const Sidebar = ({
expand,
@@ -62,10 +42,6 @@ const Sidebar = ({
const [mainNavRef, { height: mainNavHeight }] = useMeasure();
const [sidebarBodyRef, { height: sidebarBodyHeight }] = useMeasure();
- const { data: playlists }: any = useQuery(['playlists'], () =>
- apiController({ serverType: config.serverType, endpoint: 'getPlaylists' })
- );
-
const getSidebarWidth = useCallback((num: number) => {
if (num < 160) {
return 160;
@@ -118,7 +94,7 @@ const Sidebar = ({
>
{expand && misc.sidebar.coverArt && (
-
+
setShowCoverArtModal(true)}
src={
@@ -128,7 +104,7 @@ const Sidebar = ({
) || placeholderImg
}
style={{
- height: `${width}`,
+ height: `${width}px`,
width: '100%',
objectFit: 'cover',
}}
@@ -147,9 +123,7 @@ const Sidebar = ({
@@ -342,21 +316,7 @@ const Sidebar = ({
history.push('/playlist')}>
{t('Playlists')}
-
- {({ height }: any) => (
- <>
-
- {PlaylistRow}
-
- >
- )}
-
+
>
)}
diff --git a/src/components/layout/SidebarPlaylists.tsx b/src/components/layout/SidebarPlaylists.tsx
new file mode 100644
index 00000000..db7ef1d0
--- /dev/null
+++ b/src/components/layout/SidebarPlaylists.tsx
@@ -0,0 +1,53 @@
+import React from 'react';
+import { useQuery } from 'react-query';
+import { useHistory } from 'react-router-dom';
+import { AutoSizer } from 'react-virtualized';
+import { FixedSizeList as List } from 'react-window';
+import { apiController } from '../../api/controller';
+import { useAppSelector } from '../../redux/hooks';
+import { StyledButton } from '../shared/styled';
+
+const PlaylistRow = ({ data, index, style }: any) => {
+ const history = useHistory();
+
+ return (
+
+ history.push(`/playlist/${data[index].id}`)}
+ >
+ {data[index].title}
+
+
+ );
+};
+
+const SidebarPlaylists = ({ width }: any) => {
+ const config = useAppSelector((state) => state.config);
+
+ const { data: playlists }: any = useQuery(['playlists'], () =>
+ apiController({ serverType: config.serverType, endpoint: 'getPlaylists' })
+ );
+
+ return (
+
+ {({ height }: any) => (
+ <>
+
+ {PlaylistRow}
+
+ >
+ )}
+
+ );
+};
+
+export default SidebarPlaylists;