Spaces:
Running
Running
Update cointube.jsx
Browse files- cointube.jsx +7 -0
cointube.jsx
CHANGED
|
@@ -49,6 +49,7 @@ export default function App() {
|
|
| 49 |
const playerRef = useRef(null);
|
| 50 |
const coinIntervalRef = useRef(null);
|
| 51 |
const localCoinBufferRef = useRef(0);
|
|
|
|
| 52 |
|
| 53 |
useEffect(() => {
|
| 54 |
const initFirebase = async () => {
|
|
@@ -115,6 +116,12 @@ export default function App() {
|
|
| 115 |
const fetchedVideos = snapshot.docs.map(doc => ({ id: doc.id, ...doc.data() }));
|
| 116 |
if (fetchedVideos.length > 0) {
|
| 117 |
setVideos(fetchedVideos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
} else {
|
| 119 |
setVideos([{ id: '1', title: 'Pelicula Default', videoId: DEFAULT_VIDEO_ID }]);
|
| 120 |
}
|
|
|
|
| 49 |
const playerRef = useRef(null);
|
| 50 |
const coinIntervalRef = useRef(null);
|
| 51 |
const localCoinBufferRef = useRef(0);
|
| 52 |
+
const initialLoadRef = useRef(true);
|
| 53 |
|
| 54 |
useEffect(() => {
|
| 55 |
const initFirebase = async () => {
|
|
|
|
| 116 |
const fetchedVideos = snapshot.docs.map(doc => ({ id: doc.id, ...doc.data() }));
|
| 117 |
if (fetchedVideos.length > 0) {
|
| 118 |
setVideos(fetchedVideos);
|
| 119 |
+
if (initialLoadRef.current) {
|
| 120 |
+
const latestVideo = fetchedVideos[0];
|
| 121 |
+
setCurrentVideoId(latestVideo.videoId);
|
| 122 |
+
setCurrentVideoTitle(latestVideo.title);
|
| 123 |
+
initialLoadRef.current = false;
|
| 124 |
+
}
|
| 125 |
} else {
|
| 126 |
setVideos([{ id: '1', title: 'Pelicula Default', videoId: DEFAULT_VIDEO_ID }]);
|
| 127 |
}
|