Spaces:
Sleeping
Sleeping
Upload 113 files
Browse files- src/App.tsx +37 -20
- src/components/MangaCard.tsx +6 -4
- src/components/SearchResults.tsx +12 -7
src/App.tsx
CHANGED
|
@@ -190,10 +190,8 @@ function App() {
|
|
| 190 |
}, []);
|
| 191 |
|
| 192 |
useEffect(() => {
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
}
|
| 196 |
-
}, [isCategoryPlusEnabled, isCopyIdsEnabled, isDeletePlusEnabled, isCategoryMinusEnabled, isEditTitlePlusEnabled, isEtiquetadoraEnabled, isFolderPlusEnabled, isPortalPlusEnabled, isMergePlusEnabled, isTransferPlusEnabled]);
|
| 197 |
|
| 198 |
async function loadMangas() {
|
| 199 |
try {
|
|
@@ -827,7 +825,7 @@ function App() {
|
|
| 827 |
</main>
|
| 828 |
|
| 829 |
{/* Bulk Action Bar */}
|
| 830 |
-
{(selectedMangaIds.length > 0
|
| 831 |
<div className="fixed bottom-6 left-1/2 transform -translate-x-1/2 z-40 animate-in slide-in-from-bottom-4 duration-200">
|
| 832 |
<div className="bg-[#1a1a1a] border border-gray-700/50 shadow-2xl rounded-xl px-6 py-3 flex items-center gap-4">
|
| 833 |
<div className="flex flex-col">
|
|
@@ -963,21 +961,40 @@ function App() {
|
|
| 963 |
<Link className="w-4 h-4" />
|
| 964 |
Unir Mangas
|
| 965 |
</button>
|
| 966 |
-
) : isTransferPlusEnabled ? (
|
| 967 |
-
|
| 968 |
-
|
| 969 |
-
|
| 970 |
-
|
| 971 |
-
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
|
| 977 |
-
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 981 |
) : null}
|
| 982 |
<button
|
| 983 |
onClick={() => setSelectedMangaIds([])}
|
|
|
|
| 190 |
}, []);
|
| 191 |
|
| 192 |
useEffect(() => {
|
| 193 |
+
// Ya no limpiamos selectedMangaIds basado en los toggles porque los usuarios pueden seleccionar mangas directamente.
|
| 194 |
+
}, []);
|
|
|
|
|
|
|
| 195 |
|
| 196 |
async function loadMangas() {
|
| 197 |
try {
|
|
|
|
| 825 |
</main>
|
| 826 |
|
| 827 |
{/* Bulk Action Bar */}
|
| 828 |
+
{(selectedMangaIds.length > 0) && (
|
| 829 |
<div className="fixed bottom-6 left-1/2 transform -translate-x-1/2 z-40 animate-in slide-in-from-bottom-4 duration-200">
|
| 830 |
<div className="bg-[#1a1a1a] border border-gray-700/50 shadow-2xl rounded-xl px-6 py-3 flex items-center gap-4">
|
| 831 |
<div className="flex flex-col">
|
|
|
|
| 961 |
<Link className="w-4 h-4" />
|
| 962 |
Unir Mangas
|
| 963 |
</button>
|
| 964 |
+
) : isTransferPlusEnabled || true ? (
|
| 965 |
+
// En modo normal (ningún Plus activo explícitamente), mostramos Transferir o Unir si tiene sentido.
|
| 966 |
+
<>
|
| 967 |
+
{selectedMangaIds.filter(id => !mangas.find(m => m.id === id)?.is_folder).length === 2 && (
|
| 968 |
+
<button
|
| 969 |
+
onClick={() => setShowTransferPagesModal(true)}
|
| 970 |
+
className="bg-amber-600 hover:bg-amber-700 text-white px-4 py-2 rounded-lg text-sm font-bold shadow-lg shadow-amber-500/20 transition-all transform hover:scale-105 active:scale-95 flex items-center gap-2"
|
| 971 |
+
>
|
| 972 |
+
<Layers className="w-4 h-4" />
|
| 973 |
+
Transferir Páginas
|
| 974 |
+
</button>
|
| 975 |
+
)}
|
| 976 |
+
{selectedMangaIds.filter(id => !mangas.find(m => m.id === id)?.is_folder).length > 1 && (
|
| 977 |
+
<button
|
| 978 |
+
onClick={async () => {
|
| 979 |
+
const idsToMerge = selectedMangaIds.filter(id => !mangas.find(m => m.id === id)?.is_folder);
|
| 980 |
+
if (window.confirm(`¿Seguro que quieres unir ${idsToMerge.length} mangas en uno solo? Los originales serán eliminados.`)) {
|
| 981 |
+
try {
|
| 982 |
+
await mergeMangas(idsToMerge);
|
| 983 |
+
toast.success(`Se fusionaron ${idsToMerge.length} mangas correctamente.`);
|
| 984 |
+
setSelectedMangaIds([]);
|
| 985 |
+
loadMangas();
|
| 986 |
+
} catch (err) {
|
| 987 |
+
toast.error('Error al unir mangas');
|
| 988 |
+
}
|
| 989 |
+
}
|
| 990 |
+
}}
|
| 991 |
+
className="bg-emerald-600 hover:bg-emerald-700 text-white px-4 py-2 rounded-lg text-sm font-bold shadow-lg shadow-emerald-500/20 transition-all transform hover:scale-105 active:scale-95 flex items-center gap-2"
|
| 992 |
+
>
|
| 993 |
+
<Link className="w-4 h-4" />
|
| 994 |
+
Unir Mangas
|
| 995 |
+
</button>
|
| 996 |
+
)}
|
| 997 |
+
</>
|
| 998 |
) : null}
|
| 999 |
<button
|
| 1000 |
onClick={() => setSelectedMangaIds([])}
|
src/components/MangaCard.tsx
CHANGED
|
@@ -30,9 +30,10 @@ interface MangaCardProps {
|
|
| 30 |
hasSubfolders?: boolean;
|
| 31 |
isFolderAnimationEnabled?: boolean;
|
| 32 |
currentSection?: 'flow' | 'patreon' | 'onlyfans';
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
-
export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSelect, onEdit, onDelete, isCategoryPlusEnabled, isSelected, onMouseDown, onMouseEnter, folderItemCount, folderThumbnails, hasSubfolders, isFolderAnimationEnabled = true, currentSection }: MangaCardProps) {
|
| 36 |
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
| 37 |
const [currentThumbIndex, setCurrentThumbIndex] = useState(0);
|
| 38 |
const thumbnailUrl = thumbnail ? getThumbnailUrl(thumbnail) : undefined;
|
|
@@ -110,11 +111,12 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
|
|
| 110 |
}}
|
| 111 |
onMouseLeave={() => setIsHovered(false)}
|
| 112 |
onDragStart={(e) => {
|
| 113 |
-
|
| 114 |
}}
|
| 115 |
onClick={(e) => {
|
| 116 |
-
if (
|
| 117 |
-
|
|
|
|
| 118 |
e.preventDefault();
|
| 119 |
} else {
|
| 120 |
incrementMangaViews(id);
|
|
|
|
| 30 |
hasSubfolders?: boolean;
|
| 31 |
isFolderAnimationEnabled?: boolean;
|
| 32 |
currentSection?: 'flow' | 'patreon' | 'onlyfans';
|
| 33 |
+
dragStateParams?: { isDragging: boolean, action: 'select' | 'deselect' | null, startId: string | null, hasDragged: boolean };
|
| 34 |
}
|
| 35 |
|
| 36 |
+
export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSelect, onEdit, onDelete, isCategoryPlusEnabled, isSelected, onMouseDown, onMouseEnter, folderItemCount, folderThumbnails, hasSubfolders, isFolderAnimationEnabled = true, currentSection, dragStateParams }: MangaCardProps) {
|
| 37 |
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
| 38 |
const [currentThumbIndex, setCurrentThumbIndex] = useState(0);
|
| 39 |
const thumbnailUrl = thumbnail ? getThumbnailUrl(thumbnail) : undefined;
|
|
|
|
| 111 |
}}
|
| 112 |
onMouseLeave={() => setIsHovered(false)}
|
| 113 |
onDragStart={(e) => {
|
| 114 |
+
e.preventDefault();
|
| 115 |
}}
|
| 116 |
onClick={(e) => {
|
| 117 |
+
if (dragStateParams?.hasDragged) {
|
| 118 |
+
e.preventDefault();
|
| 119 |
+
} else if (isCategoryPlusEnabled || isSelected) {
|
| 120 |
e.preventDefault();
|
| 121 |
} else {
|
| 122 |
incrementMangaViews(id);
|
src/components/SearchResults.tsx
CHANGED
|
@@ -111,12 +111,12 @@ export function SearchResults({
|
|
| 111 |
isFolderAnimationEnabled = true,
|
| 112 |
currentSection,
|
| 113 |
}: SearchResultsProps) {
|
| 114 |
-
const [dragState, setDragState] = useState<{ isDragging: boolean, action: 'select' | 'deselect' | null }>({ isDragging: false, action: null });
|
| 115 |
|
| 116 |
useEffect(() => {
|
| 117 |
const handleMouseUp = () => {
|
| 118 |
if (dragState.isDragging) {
|
| 119 |
-
setDragState({ isDragging: false, action: null });
|
| 120 |
}
|
| 121 |
};
|
| 122 |
window.addEventListener('mouseup', handleMouseUp);
|
|
@@ -131,18 +131,22 @@ export function SearchResults({
|
|
| 131 |
};
|
| 132 |
|
| 133 |
const handleMouseDown = (e: React.MouseEvent, id: string) => {
|
| 134 |
-
if (!isCategoryPlusEnabled) return;
|
| 135 |
if (e.button !== 0) return; // Only left click
|
| 136 |
|
| 137 |
const isCurrentlySelected = selectedMangaIds.includes(id);
|
| 138 |
const action = isCurrentlySelected ? 'deselect' : 'select';
|
| 139 |
-
setDragState({ isDragging: true, action });
|
| 140 |
-
|
| 141 |
-
handleSetSelection(id, action === 'select');
|
| 142 |
};
|
| 143 |
|
| 144 |
const handleMouseEnter = (id: string) => {
|
| 145 |
-
if (!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
handleSetSelection(id, dragState.action === 'select');
|
| 147 |
};
|
| 148 |
|
|
@@ -334,6 +338,7 @@ export function SearchResults({
|
|
| 334 |
isSelected={selectedMangaIds.includes(item.id)}
|
| 335 |
onMouseDown={(e) => handleMouseDown(e, item.id)}
|
| 336 |
onMouseEnter={() => handleMouseEnter(item.id)}
|
|
|
|
| 337 |
folderItemCount={item.manga?.is_folder ? allMangas.filter(m => m.folder_id === item.id).length : undefined}
|
| 338 |
folderThumbnails={item.manga?.is_folder ? getFolderThumbnails(item.id, allMangas) : undefined}
|
| 339 |
hasSubfolders={item.manga?.is_folder ? allMangas.some(m => m.folder_id === item.id && m.is_folder) : false}
|
|
|
|
| 111 |
isFolderAnimationEnabled = true,
|
| 112 |
currentSection,
|
| 113 |
}: SearchResultsProps) {
|
| 114 |
+
const [dragState, setDragState] = useState<{ isDragging: boolean, action: 'select' | 'deselect' | null, startId: string | null, hasDragged: boolean }>({ isDragging: false, action: null, startId: null, hasDragged: false });
|
| 115 |
|
| 116 |
useEffect(() => {
|
| 117 |
const handleMouseUp = () => {
|
| 118 |
if (dragState.isDragging) {
|
| 119 |
+
setDragState({ isDragging: false, action: null, startId: null, hasDragged: false });
|
| 120 |
}
|
| 121 |
};
|
| 122 |
window.addEventListener('mouseup', handleMouseUp);
|
|
|
|
| 131 |
};
|
| 132 |
|
| 133 |
const handleMouseDown = (e: React.MouseEvent, id: string) => {
|
|
|
|
| 134 |
if (e.button !== 0) return; // Only left click
|
| 135 |
|
| 136 |
const isCurrentlySelected = selectedMangaIds.includes(id);
|
| 137 |
const action = isCurrentlySelected ? 'deselect' : 'select';
|
| 138 |
+
setDragState({ isDragging: true, action, startId: id, hasDragged: false });
|
|
|
|
|
|
|
| 139 |
};
|
| 140 |
|
| 141 |
const handleMouseEnter = (id: string) => {
|
| 142 |
+
if (!dragState.isDragging || !dragState.action) return;
|
| 143 |
+
|
| 144 |
+
if (!dragState.hasDragged && dragState.startId) {
|
| 145 |
+
// First drag movement over a new card
|
| 146 |
+
handleSetSelection(dragState.startId, dragState.action === 'select');
|
| 147 |
+
setDragState(prev => ({ ...prev, hasDragged: true }));
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
handleSetSelection(id, dragState.action === 'select');
|
| 151 |
};
|
| 152 |
|
|
|
|
| 338 |
isSelected={selectedMangaIds.includes(item.id)}
|
| 339 |
onMouseDown={(e) => handleMouseDown(e, item.id)}
|
| 340 |
onMouseEnter={() => handleMouseEnter(item.id)}
|
| 341 |
+
dragStateParams={dragState}
|
| 342 |
folderItemCount={item.manga?.is_folder ? allMangas.filter(m => m.folder_id === item.id).length : undefined}
|
| 343 |
folderThumbnails={item.manga?.is_folder ? getFolderThumbnails(item.id, allMangas) : undefined}
|
| 344 |
hasSubfolders={item.manga?.is_folder ? allMangas.some(m => m.folder_id === item.id && m.is_folder) : false}
|