|
431 | 431 | const isScenesTab = pathname.endsWith('/scenes'); |
432 | 432 | const isMarkersTab = pathname.endsWith('/markers'); |
433 | 433 | const isGroupsTab = pathname.endsWith('/groups'); |
434 | | - // console.log("Tag page details:", { pathname, isScenesTab, isMarkersTab, isGroupsTab }); |
| 434 | + const isPerformersTab = pathname.endsWith('/performers'); |
| 435 | + // console.log("Tag page details:", { pathname, isScenesTab, isMarkersTab, isGroupsTab, isPerformersTab }); |
435 | 436 |
|
436 | 437 | let scenePreviews = []; |
437 | 438 | let markerPreviews = []; |
438 | 439 | let groupScenePreviews = []; // Videos from scenes in groups linked to the tag |
| 440 | + let performerScenePreviews = []; // Videos from scenes with performers who have the tag |
439 | 441 |
|
440 | 442 | const scenesQuery = ` |
441 | 443 | query FindScenesForTag($id: ID!) { |
|
516 | 518 |
|
517 | 519 | } |
518 | 520 |
|
519 | | - if (isScenesTab || (!isScenesTab && !isMarkersTab)) { // Fetch scenes for scenes tab or main tag page |
| 521 | + if (isPerformersTab) { // Fetch scenes from performers who have the tag for the performers tab |
| 522 | + // console.log("Fetching scenes from performers for tag page..."); |
| 523 | + // First, find performers associated with the tag |
| 524 | + const performersQuery = ` |
| 525 | + query FindPerformersForTag($tagId: ID!) { |
| 526 | + findPerformers(performer_filter: { tags: { value: [$tagId], modifier: INCLUDES_ALL } }) { |
| 527 | + performers { |
| 528 | + id |
| 529 | + } |
| 530 | + } |
| 531 | + } |
| 532 | + `; |
| 533 | + const performersResponse = await csLib.callGQL({ query: performersQuery, variables: { tagId: id } }); |
| 534 | + // console.log("GraphQL Performers Response (Tags page, Performers tab):", performersResponse); |
| 535 | + |
| 536 | + const performerIds = performersResponse?.findPerformers?.performers?.map(performer => performer.id) || []; |
| 537 | + // console.log("Performer IDs associated with tag:", performerIds); |
| 538 | + |
| 539 | + if (performerIds.length > 0) { |
| 540 | + // Then, find scenes associated with these performers |
| 541 | + const scenesByPerformerQuery = ` |
| 542 | + query FindScenesByPerformerIds($performerIds: [ID!]) { |
| 543 | + findScenes(scene_filter: { performers: { value: $performerIds, modifier: INCLUDES } }) { |
| 544 | + scenes { |
| 545 | + id |
| 546 | + paths { |
| 547 | + preview |
| 548 | + } |
| 549 | + } |
| 550 | + } |
| 551 | + } |
| 552 | + `; |
| 553 | + const scenesByPerformerResponse = await csLib.callGQL({ query: scenesByPerformerQuery, variables: { performerIds } }); |
| 554 | + // console.log("GraphQL Scenes by Performer Response (Tags page, Performers tab):", scenesByPerformerResponse); |
| 555 | + |
| 556 | + performerScenePreviews = scenesByPerformerResponse?.findScenes?.scenes |
| 557 | + ?.filter(scene => scene.paths?.preview) |
| 558 | + .map(scene => `${scene.paths.preview}?_ts=${Date.now()}`) || []; |
| 559 | + // console.log("Performer scene preview URLs (Tags page, Performers tab):", performerScenePreviews); |
| 560 | + |
| 561 | + // Shuffle the collected performer scene preview URLs |
| 562 | + for (let i = performerScenePreviews.length - 1; i > 0; i--) { |
| 563 | + const j = Math.floor(Math.random() * (i + 1)); |
| 564 | + [performerScenePreviews[i], performerScenePreviews[j]] = [performerScenePreviews[j], performerScenePreviews[i]]; |
| 565 | + } |
| 566 | + // console.log("Shuffled performer scene preview URLs (Tags page, Performers tab):", performerScenePreviews); |
| 567 | + } else { |
| 568 | + // console.log("No performers found for this tag."); |
| 569 | + } |
| 570 | + |
| 571 | + } |
| 572 | + |
| 573 | + if (isScenesTab || (!isScenesTab && !isMarkersTab && !isGroupsTab && !isPerformersTab)) { // Fetch scenes for scenes tab or main tag page |
520 | 574 | // console.log("Fetching scenes for tag page..."); |
521 | 575 | const scenesResponse = await csLib.callGQL({ query: scenesQuery, variables: { id } }); |
522 | 576 | // console.log("GraphQL Scenes Response (Tags page):", scenesResponse); |
|
526 | 580 | // console.log("Scene preview URLs (Tags page):", scenePreviews); |
527 | 581 | } |
528 | 582 |
|
529 | | - if (isMarkersTab || (!isScenesTab && !isMarkersTab)) { // Fetch markers for markers tab or main tag page |
| 583 | + if (isMarkersTab || (!isScenesTab && !isMarkersTab && !isGroupsTab && !isPerformersTab)) { // Fetch markers for markers tab or main tag page |
530 | 584 | // console.log("Fetching markers for tag page..."); |
531 | 585 | const markersResponse = await csLib.callGQL({ query: markersQuery, variables: { id } }); |
532 | 586 | // console.log("GraphQL Markers Response (Tags page):", markersResponse); |
|
540 | 594 | if (isGroupsTab) { |
541 | 595 | videoUrls = groupScenePreviews; // Only group scene previews on groups tab |
542 | 596 | // console.log("Video URLs (Groups tab):", videoUrls); |
| 597 | + } else if (isPerformersTab) { |
| 598 | + videoUrls = performerScenePreviews; // Only performer scene previews on performers tab |
| 599 | + // console.log("Video URLs (Performers tab):", videoUrls); |
543 | 600 | } else if (isMarkersTab) { |
544 | 601 | videoUrls = markerPreviews; // Only marker previews on markers tab |
545 | 602 | // console.log("Video URLs (Markers tab):", videoUrls); |
|
598 | 655 | currentVideoIndex = Math.floor(Math.random() * videoUrls.length); |
599 | 656 | if (isGroupsTab) { |
600 | 657 | // console.log(`Starting slideshow with a random group scene preview at index: ${currentVideoIndex} (out of ${videoUrls.length} total videos) on Groups tab.`); |
| 658 | + } else if (isPerformersTab) { |
| 659 | + // console.log(`Starting slideshow with a random performer scene preview at index: ${currentVideoIndex} (out of ${videoUrls.length} total videos) on Performers tab.`); |
601 | 660 | } else if (isMarkersTab) { |
602 | 661 | // console.log(`Starting slideshow with a random marker preview at index: ${currentVideoIndex} (out of ${videoUrls.length} total videos) on Markers tab.`); |
603 | 662 | } else if (isScenesTab) { |
|
0 commit comments