add multiselect bulk reindex

This commit is contained in:
Simon 2026-04-18 09:44:11 +07:00
parent 5b1cd24a23
commit d8e35d2d52
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
5 changed files with 20 additions and 7 deletions

View File

@ -8,7 +8,7 @@ export const ReindexTypeEnum = {
playlist: 'playlist',
};
const queueReindex = async (id: string, type: ReindexType, reindexVideos = false) => {
const queueReindex = async (id: string[], type: ReindexType, reindexVideos = false) => {
let params = '';
if (reindexVideos) {
params = '?extract_videos=true';
@ -16,7 +16,7 @@ const queueReindex = async (id: string, type: ReindexType, reindexVideos = false
return APIClient(`/api/refresh/${params}`, {
method: 'POST',
body: { [type]: [id] },
body: { [type]: id },
});
};

View File

@ -22,6 +22,9 @@ import { useVideoSelectionStore } from '../stores/VideoSelectionStore';
import Button from './Button';
import updateDownloadQueue from '../api/actions/updateDownloadQueue';
import { HideWatchedType } from '../configuration/constants/HideWatched';
import queueReindex from '../api/actions/queueReindex';
import { useOutletContext } from 'react-router-dom';
import { ChannelBaseOutletContextType } from '../pages/ChannelAbout';
type FilterbarProps = {
viewStyle: ViewStyleNamesType;
@ -49,6 +52,7 @@ const Filterbar = ({
const [showHidden, setShowHidden] = useState(false);
const { filterHeight, setFilterHeight, showFilterItems, setShowFilterItems } =
useFilterBarTempConf();
const { setStartNotification } = useOutletContext() as ChannelBaseOutletContextType;
const currentViewStyle = userConfig[viewStyle];
const currentHideWatched = userConfig[hideWatched];
@ -84,11 +88,20 @@ const Filterbar = ({
});
};
const reindexSelected = async (ids: string[]) => {
queueReindex(ids, 'video');
if (setStartNotification !== undefined) setStartNotification(true);
};
const actionList = [
{
label: 'Redownload',
handler: redownloadSelected,
},
{
label: 'Reindex',
handler: reindexSelected,
},
];
const handleActionSelectChange = (e: React.ChangeEvent<HTMLSelectElement>) => {

View File

@ -183,7 +183,7 @@ const ChannelAbout = () => {
label="Reindex"
title={`Reindex Channel ${channel.channel_name}`}
onClick={async () => {
await queueReindex(channelId, ReindexTypeEnum.channel as ReindexType);
await queueReindex([channelId], ReindexTypeEnum.channel as ReindexType);
setReindex(true);
setStartNotification(true);
@ -194,7 +194,7 @@ const ChannelAbout = () => {
title={`Reindex Videos of ${channel.channel_name}`}
onClick={async () => {
await queueReindex(
channelId,
[channelId],
ReindexTypeEnum.channel as ReindexType,
true,
);

View File

@ -284,7 +284,7 @@ const Playlist = () => {
onClick={async () => {
setReindex(true);
await queueReindex(playlist.playlist_id, 'playlist');
await queueReindex([playlist.playlist_id], 'playlist');
}}
/>
)}{' '}
@ -294,7 +294,7 @@ const Playlist = () => {
onClick={async () => {
setReindex(true);
await queueReindex(playlist.playlist_id, 'playlist', true);
await queueReindex([playlist.playlist_id], 'playlist', true);
}}
/>
</div>

View File

@ -342,7 +342,7 @@ const Video = () => {
label="Reindex"
title={`Reindex ${video.title}`}
onClick={async () => {
await queueReindex(video.youtube_id, 'video');
await queueReindex([video.youtube_id], 'video');
setReindex(true);
}}
/>