mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 18:33:33 +00:00
Lint all files
This commit is contained in:
parent
22af76b4d6
commit
30e52ebb54
334 changed files with 76519 additions and 75932 deletions
|
|
@ -12,175 +12,175 @@ import { LibraryItem, SearchQuery } from '/@/renderer/api/types';
|
|||
import { useLocation, useParams } from 'react-router';
|
||||
|
||||
const SearchRoute = () => {
|
||||
const { state: locationState } = useLocation();
|
||||
const localNavigationId = useId();
|
||||
const navigationId = locationState?.navigationId || localNavigationId;
|
||||
const { itemType } = useParams() as { itemType: string };
|
||||
const tableRef = useRef<AgGridReactType | null>(null);
|
||||
const server = useCurrentServer();
|
||||
const queryClient = useQueryClient();
|
||||
const { state: locationState } = useLocation();
|
||||
const localNavigationId = useId();
|
||||
const navigationId = locationState?.navigationId || localNavigationId;
|
||||
const { itemType } = useParams() as { itemType: string };
|
||||
const tableRef = useRef<AgGridReactType | null>(null);
|
||||
const server = useCurrentServer();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const getDatasource = useCallback(
|
||||
(searchQuery: string, itemType: LibraryItem) => {
|
||||
let dataSource: IDatasource | undefined;
|
||||
const getDatasource = useCallback(
|
||||
(searchQuery: string, itemType: LibraryItem) => {
|
||||
let dataSource: IDatasource | undefined;
|
||||
|
||||
switch (itemType) {
|
||||
case LibraryItem.ALBUM:
|
||||
dataSource = {
|
||||
getRows: async (params) => {
|
||||
const limit = params.endRow - params.startRow;
|
||||
const startIndex = params.startRow;
|
||||
switch (itemType) {
|
||||
case LibraryItem.ALBUM:
|
||||
dataSource = {
|
||||
getRows: async (params) => {
|
||||
const limit = params.endRow - params.startRow;
|
||||
const startIndex = params.startRow;
|
||||
|
||||
const query: SearchQuery = {
|
||||
albumArtistLimit: 0,
|
||||
albumArtistStartIndex: 0,
|
||||
albumLimit: limit,
|
||||
albumStartIndex: startIndex,
|
||||
query: searchQuery || ' ',
|
||||
songLimit: 0,
|
||||
songStartIndex: 0,
|
||||
};
|
||||
const query: SearchQuery = {
|
||||
albumArtistLimit: 0,
|
||||
albumArtistStartIndex: 0,
|
||||
albumLimit: limit,
|
||||
albumStartIndex: startIndex,
|
||||
query: searchQuery || ' ',
|
||||
songLimit: 0,
|
||||
songStartIndex: 0,
|
||||
};
|
||||
|
||||
const queryKey = queryKeys.search.list(server?.id || '', query);
|
||||
const queryKey = queryKeys.search.list(server?.id || '', query);
|
||||
|
||||
const res = await queryClient.fetchQuery(
|
||||
queryKey,
|
||||
async ({ signal }) =>
|
||||
api.controller.search({
|
||||
apiClientProps: {
|
||||
server,
|
||||
signal,
|
||||
},
|
||||
query,
|
||||
}),
|
||||
{ cacheTime: 1000 * 60 },
|
||||
);
|
||||
const res = await queryClient.fetchQuery(
|
||||
queryKey,
|
||||
async ({ signal }) =>
|
||||
api.controller.search({
|
||||
apiClientProps: {
|
||||
server,
|
||||
signal,
|
||||
},
|
||||
query,
|
||||
}),
|
||||
{ cacheTime: 1000 * 60 },
|
||||
);
|
||||
|
||||
if (!res) return;
|
||||
if (!res) return;
|
||||
|
||||
const items = res.albums || [];
|
||||
const numOfItems = items.length;
|
||||
const items = res.albums || [];
|
||||
const numOfItems = items.length;
|
||||
|
||||
let lastRow = -1;
|
||||
if (numOfItems < limit) {
|
||||
lastRow = startIndex + numOfItems;
|
||||
}
|
||||
let lastRow = -1;
|
||||
if (numOfItems < limit) {
|
||||
lastRow = startIndex + numOfItems;
|
||||
}
|
||||
|
||||
params.successCallback(items, lastRow);
|
||||
},
|
||||
};
|
||||
break;
|
||||
case LibraryItem.ALBUM_ARTIST:
|
||||
dataSource = {
|
||||
getRows: async (params) => {
|
||||
const limit = params.endRow - params.startRow;
|
||||
const startIndex = params.startRow;
|
||||
params.successCallback(items, lastRow);
|
||||
},
|
||||
};
|
||||
break;
|
||||
case LibraryItem.ALBUM_ARTIST:
|
||||
dataSource = {
|
||||
getRows: async (params) => {
|
||||
const limit = params.endRow - params.startRow;
|
||||
const startIndex = params.startRow;
|
||||
|
||||
const query: SearchQuery = {
|
||||
albumArtistLimit: limit,
|
||||
albumArtistStartIndex: startIndex,
|
||||
albumLimit: 0,
|
||||
albumStartIndex: 0,
|
||||
query: searchQuery || ' ',
|
||||
songLimit: 0,
|
||||
songStartIndex: 0,
|
||||
};
|
||||
const query: SearchQuery = {
|
||||
albumArtistLimit: limit,
|
||||
albumArtistStartIndex: startIndex,
|
||||
albumLimit: 0,
|
||||
albumStartIndex: 0,
|
||||
query: searchQuery || ' ',
|
||||
songLimit: 0,
|
||||
songStartIndex: 0,
|
||||
};
|
||||
|
||||
const queryKey = queryKeys.search.list(server?.id || '', query);
|
||||
const queryKey = queryKeys.search.list(server?.id || '', query);
|
||||
|
||||
const res = await queryClient.fetchQuery(
|
||||
queryKey,
|
||||
async ({ signal }) =>
|
||||
api.controller.search({
|
||||
apiClientProps: {
|
||||
server,
|
||||
signal,
|
||||
},
|
||||
query,
|
||||
}),
|
||||
{ cacheTime: 1000 * 60 },
|
||||
);
|
||||
const res = await queryClient.fetchQuery(
|
||||
queryKey,
|
||||
async ({ signal }) =>
|
||||
api.controller.search({
|
||||
apiClientProps: {
|
||||
server,
|
||||
signal,
|
||||
},
|
||||
query,
|
||||
}),
|
||||
{ cacheTime: 1000 * 60 },
|
||||
);
|
||||
|
||||
if (!res) return;
|
||||
if (!res) return;
|
||||
|
||||
const items = res.albumArtists || [];
|
||||
const numOfItems = items.length;
|
||||
const items = res.albumArtists || [];
|
||||
const numOfItems = items.length;
|
||||
|
||||
let lastRow = -1;
|
||||
if (numOfItems < limit) {
|
||||
lastRow = startIndex + numOfItems;
|
||||
}
|
||||
let lastRow = -1;
|
||||
if (numOfItems < limit) {
|
||||
lastRow = startIndex + numOfItems;
|
||||
}
|
||||
|
||||
params.successCallback(items, lastRow);
|
||||
},
|
||||
};
|
||||
break;
|
||||
case LibraryItem.SONG:
|
||||
dataSource = {
|
||||
getRows: async (params) => {
|
||||
const limit = params.endRow - params.startRow;
|
||||
const startIndex = params.startRow;
|
||||
params.successCallback(items, lastRow);
|
||||
},
|
||||
};
|
||||
break;
|
||||
case LibraryItem.SONG:
|
||||
dataSource = {
|
||||
getRows: async (params) => {
|
||||
const limit = params.endRow - params.startRow;
|
||||
const startIndex = params.startRow;
|
||||
|
||||
const query: SearchQuery = {
|
||||
albumArtistLimit: 0,
|
||||
albumArtistStartIndex: 0,
|
||||
albumLimit: 0,
|
||||
albumStartIndex: 0,
|
||||
query: searchQuery || ' ',
|
||||
songLimit: limit,
|
||||
songStartIndex: startIndex,
|
||||
};
|
||||
const query: SearchQuery = {
|
||||
albumArtistLimit: 0,
|
||||
albumArtistStartIndex: 0,
|
||||
albumLimit: 0,
|
||||
albumStartIndex: 0,
|
||||
query: searchQuery || ' ',
|
||||
songLimit: limit,
|
||||
songStartIndex: startIndex,
|
||||
};
|
||||
|
||||
const queryKey = queryKeys.search.list(server?.id || '', query);
|
||||
const queryKey = queryKeys.search.list(server?.id || '', query);
|
||||
|
||||
const res = await queryClient.fetchQuery(
|
||||
queryKey,
|
||||
async ({ signal }) =>
|
||||
api.controller.search({
|
||||
apiClientProps: {
|
||||
server,
|
||||
signal,
|
||||
},
|
||||
query,
|
||||
}),
|
||||
{ cacheTime: 1000 * 60 },
|
||||
);
|
||||
const res = await queryClient.fetchQuery(
|
||||
queryKey,
|
||||
async ({ signal }) =>
|
||||
api.controller.search({
|
||||
apiClientProps: {
|
||||
server,
|
||||
signal,
|
||||
},
|
||||
query,
|
||||
}),
|
||||
{ cacheTime: 1000 * 60 },
|
||||
);
|
||||
|
||||
if (!res) return;
|
||||
if (!res) return;
|
||||
|
||||
const items = res.songs || [];
|
||||
const numOfItems = items.length;
|
||||
const items = res.songs || [];
|
||||
const numOfItems = items.length;
|
||||
|
||||
let lastRow = -1;
|
||||
if (numOfItems < limit) {
|
||||
lastRow = startIndex + numOfItems;
|
||||
}
|
||||
let lastRow = -1;
|
||||
if (numOfItems < limit) {
|
||||
lastRow = startIndex + numOfItems;
|
||||
}
|
||||
|
||||
params.successCallback(items, lastRow);
|
||||
},
|
||||
};
|
||||
break;
|
||||
}
|
||||
params.successCallback(items, lastRow);
|
||||
},
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
return dataSource;
|
||||
},
|
||||
[queryClient, server],
|
||||
);
|
||||
return dataSource;
|
||||
},
|
||||
[queryClient, server],
|
||||
);
|
||||
|
||||
return (
|
||||
<AnimatedPage key={`search-${navigationId}`}>
|
||||
<SearchHeader
|
||||
getDatasource={getDatasource}
|
||||
navigationId={navigationId}
|
||||
tableRef={tableRef}
|
||||
/>
|
||||
<SearchContent
|
||||
key={`page-${itemType}`}
|
||||
getDatasource={getDatasource}
|
||||
tableRef={tableRef}
|
||||
/>
|
||||
</AnimatedPage>
|
||||
);
|
||||
return (
|
||||
<AnimatedPage key={`search-${navigationId}`}>
|
||||
<SearchHeader
|
||||
getDatasource={getDatasource}
|
||||
navigationId={navigationId}
|
||||
tableRef={tableRef}
|
||||
/>
|
||||
<SearchContent
|
||||
key={`page-${itemType}`}
|
||||
getDatasource={getDatasource}
|
||||
tableRef={tableRef}
|
||||
/>
|
||||
</AnimatedPage>
|
||||
);
|
||||
};
|
||||
|
||||
export default SearchRoute;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue