codebybrody commited on
Commit
4e22014
·
verified ·
1 Parent(s): b2e5c23

Upload 105 files

Browse files
Files changed (2) hide show
  1. src/App.tsx +7 -1
  2. src/components/SearchResults.tsx +29 -1
src/App.tsx CHANGED
@@ -540,7 +540,13 @@ function App() {
540
  if (!folder) return null;
541
  return (
542
  <div className="mb-6 flex items-center gap-4 bg-[#1a1a1a] p-4 rounded-xl border border-gray-800 animate-in slide-in-from-top-2">
543
- <button onClick={() => { window.location.hash = ''; }} className="p-2 hover:bg-gray-800 rounded-lg text-white transition-colors">
 
 
 
 
 
 
544
  <ArrowLeft className="w-5 h-5" />
545
  </button>
546
  <div className="w-10 h-10 rounded-lg bg-gray-800 flex items-center justify-center">
 
540
  if (!folder) return null;
541
  return (
542
  <div className="mb-6 flex items-center gap-4 bg-[#1a1a1a] p-4 rounded-xl border border-gray-800 animate-in slide-in-from-top-2">
543
+ <button onClick={() => {
544
+ if (folder.folder_id) {
545
+ window.location.hash = `folder/${folder.folder_id}`;
546
+ } else {
547
+ window.location.hash = '';
548
+ }
549
+ }} className="p-2 hover:bg-gray-800 rounded-lg text-white transition-colors">
550
  <ArrowLeft className="w-5 h-5" />
551
  </button>
552
  <div className="w-10 h-10 rounded-lg bg-gray-800 flex items-center justify-center">
src/components/SearchResults.tsx CHANGED
@@ -30,6 +30,34 @@ interface SearchResultsProps {
30
 
31
  const ITEMS_PER_PAGE = 24;
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  export function SearchResults({
34
  items,
35
  searchTerm,
@@ -267,7 +295,7 @@ export function SearchResults({
267
  onMouseDown={(e) => handleMouseDown(e, item.id)}
268
  onMouseEnter={() => handleMouseEnter(item.id)}
269
  folderItemCount={item.manga?.is_folder ? allMangas.filter(m => m.folder_id === item.id).length : undefined}
270
- folderThumbnails={item.manga?.is_folder ? allMangas.filter(m => m.folder_id === item.id && m.thumbnail_url).slice(0, 4).map(m => m.thumbnail_url!) : undefined}
271
  />
272
  </div>
273
  ))}
 
30
 
31
  const ITEMS_PER_PAGE = 24;
32
 
33
+ function getFolderThumbnails(folderId: string, mangas: Manga[], limit = 4, visited = new Set<string>()): string[] {
34
+ if (visited.has(folderId)) return [];
35
+ visited.add(folderId);
36
+
37
+ const children = mangas.filter(m => m.folder_id === folderId);
38
+ const thumbnails: string[] = [];
39
+
40
+ for (const child of children) {
41
+ if (thumbnails.length >= limit) break;
42
+
43
+ if (child.thumbnail_url) {
44
+ if (!thumbnails.includes(child.thumbnail_url)) {
45
+ thumbnails.push(child.thumbnail_url);
46
+ }
47
+ } else if (child.is_folder) {
48
+ const childThumbnails = getFolderThumbnails(child.id, mangas, limit - thumbnails.length, visited);
49
+ for (const t of childThumbnails) {
50
+ if (thumbnails.length >= limit) break;
51
+ if (!thumbnails.includes(t)) {
52
+ thumbnails.push(t);
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ return thumbnails;
59
+ }
60
+
61
  export function SearchResults({
62
  items,
63
  searchTerm,
 
295
  onMouseDown={(e) => handleMouseDown(e, item.id)}
296
  onMouseEnter={() => handleMouseEnter(item.id)}
297
  folderItemCount={item.manga?.is_folder ? allMangas.filter(m => m.folder_id === item.id).length : undefined}
298
+ folderThumbnails={item.manga?.is_folder ? getFolderThumbnails(item.id, allMangas) : undefined}
299
  />
300
  </div>
301
  ))}