Fix search: clicking video plays ALL channel videos, added Play All button

This commit is contained in:
Khoa.vo 2025-12-19 20:42:25 +07:00
parent df98b36c47
commit a372f98e4b
2 changed files with 33 additions and 10 deletions

View file

@ -1,3 +1,4 @@
[ [
"nhythanh_04" "nhythanh_04",
"po.trann77"
] ]

View file

@ -1090,12 +1090,28 @@ export const Feed: React.FC = () => {
</button> </button>
)} )}
</div> </div>
<button <div className="flex items-center gap-2">
onClick={() => setSearchResults([])} {/* Play All Button */}
className="text-white/30 text-xs hover:text-white/60" <button
> onClick={() => {
Clear const playableVideos = searchResults.filter(v => v.url);
</button> if (playableVideos.length > 0) {
setVideos(playableVideos);
setCurrentIndex(0);
setActiveTab('foryou');
}
}}
className="px-3 py-1 bg-gradient-to-r from-cyan-500 to-pink-500 rounded-full text-xs font-medium text-white"
>
Play All
</button>
<button
onClick={() => setSearchResults([])}
className="text-white/30 text-xs hover:text-white/60"
>
Clear
</button>
</div>
</div> </div>
{/* Video Grid */} {/* Video Grid */}
@ -1109,9 +1125,15 @@ export const Feed: React.FC = () => {
}`} }`}
onClick={() => { onClick={() => {
if (!video.url) return; if (!video.url) return;
setVideos(prev => [video, ...prev.filter(v => v.id !== video.id)]); // Load ALL search results into the feed, starting from clicked video
setCurrentIndex(0); const playableVideos = searchResults.filter(v => v.url);
setActiveTab('foryou'); if (playableVideos.length > 0) {
setVideos(playableVideos);
// Set current index to the clicked video's position in playable videos
const newIndex = playableVideos.findIndex(v => v.id === video.id);
setCurrentIndex(newIndex >= 0 ? newIndex : 0);
setActiveTab('foryou');
}
}} }}
> >
{/* Thumbnail with loading placeholder */} {/* Thumbnail with loading placeholder */}