mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
Add Rescan Channel option to channels tab
Co-authored-by: xCyanGrizzly <53275238+xCyanGrizzly@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
deleteChannel,
|
||||
toggleChannelActive,
|
||||
setChannelType,
|
||||
rescanChannel,
|
||||
} from "../actions";
|
||||
import { DataTable } from "@/components/shared/data-table";
|
||||
import { DeleteDialog } from "@/components/shared/delete-dialog";
|
||||
@@ -22,6 +23,7 @@ interface ChannelsTabProps {
|
||||
export function ChannelsTab({ channels, globalDestination }: ChannelsTabProps) {
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
const [rescanId, setRescanId] = useState<string | null>(null);
|
||||
|
||||
const columns = getChannelColumns({
|
||||
onToggleActive: (id) => {
|
||||
@@ -39,6 +41,7 @@ export function ChannelsTab({ channels, globalDestination }: ChannelsTabProps) {
|
||||
else toast.error(result.error);
|
||||
});
|
||||
},
|
||||
onRescan: (id) => setRescanId(id),
|
||||
});
|
||||
|
||||
const { table } = useDataTable({
|
||||
@@ -60,6 +63,19 @@ export function ChannelsTab({ channels, globalDestination }: ChannelsTabProps) {
|
||||
});
|
||||
};
|
||||
|
||||
const handleRescan = () => {
|
||||
if (!rescanId) return;
|
||||
startTransition(async () => {
|
||||
const result = await rescanChannel(rescanId);
|
||||
if (result.success) {
|
||||
toast.success("Channel scan progress reset — it will be fully rescanned on the next sync");
|
||||
setRescanId(null);
|
||||
} else {
|
||||
toast.error(result.error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<DestinationCard destination={globalDestination} />
|
||||
@@ -83,6 +99,16 @@ export function ChannelsTab({ channels, globalDestination }: ChannelsTabProps) {
|
||||
onConfirm={handleDelete}
|
||||
isLoading={isPending}
|
||||
/>
|
||||
|
||||
<DeleteDialog
|
||||
open={!!rescanId}
|
||||
onOpenChange={(open) => !open && setRescanId(null)}
|
||||
title="Rescan Channel"
|
||||
description="This will reset all scan progress for this channel. On the next sync the worker will re-process every message from the beginning. Packages that are already in the library will be skipped (deduplication by hash), but any missing files will be re-downloaded and re-uploaded. This may take a long time for large channels."
|
||||
confirmLabel="Rescan"
|
||||
onConfirm={handleRescan}
|
||||
isLoading={isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user