Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

rerender all videos after channel added

Christian Fei1017d7c6ae3f
diff --git a/client/main.js b/client/main.js
index 52aa158..485882e 100644
--- a/client/main.js
+++ b/client/main.js
@@ -180,23 +180,6 @@ eventSource.onmessage = (message) => {
updateDownloadedVideos(allVideos)
window.videos = data.videos
}
- if (data.type === 'channel' && data.name && data.videos) {
- data.videos
- .sort((a, b) => +new Date(b.publishedAt) - +new Date(a.publishedAt))
- .forEach(video => {
- const $video = document.querySelector(`[data-video-id="${video.id}"]`)
- if ($video) {
- $video.dataset['data'] = JSON.stringify(video)
- console.log('video exists', video.id)
- return
- }
- console.log('video does not exist. prepending', video.id)
- $videosContainer.insertBefore(createVideoElement(video), $videosContainer.firstChild)
- })
-
- updateDownloadedVideos(data.videos)
- window.videos[data.name] = data.videos
- }
if (data.type === 'summary' && data.videoId && data.summary && data.transcript) {
const $video = document.querySelector(`[data-video-id="${data.videoId}"]`)
if ($video) {
diff --git a/lib/server.js b/lib/server.js
index 1d4b08a..407c62f 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -73,7 +73,7 @@ export function createServer ({repo, connections = []}) {
const videos = await updateAndPersistVideosForChannel(name, repo)
if (Array.isArray(videos)) {
repo.addChannel(name)
- broadcastSSE(JSON.stringify({type: 'channel', name, videos}), connections)
+ broadcastSSE(JSON.stringify({type: 'all', videos}), connections)
res.writeHead(201, { 'Content-Type': 'text/plain' })
return res.end('Channel added')
}