A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
refactor: move patchVideo to repo
Christian Fei14d456da1ab2
diff --git a/lib/repository.js b/lib/repository.jsindex 979f1a2..a7be119 100644--- a/lib/repository.js+++ b/lib/repository.js@@ -86,4 +86,10 @@ export default class Repository {})this.saveVideos()}+ patchVideo(video) {+ const savedVideo = this.getVideo(video.id)+ if (!savedVideo) return Object.assign(video, {addedAt: Date.now()})+ Object.assign(savedVideo, video)+ return savedVideo+ }}\ No newline at end of filediff --git a/lib/server.js b/lib/server.jsindex 280ce9b..af8792c 100644--- a/lib/server.js+++ b/lib/server.js@@ -254,16 +254,9 @@ async function updateAndPersistVideosForChannel(name, repo, callback = () => {})let videos = await getVideosFor(name)console.log('received videos for ', name, videos?.length)if (videos) {- videos = videos.map(v => patchVideo(v, repo))+ videos = videos.map(v => repo.patchVideo(v))repo.upsertVideos(videos)callback({name, videos})}return videos}--function patchVideo(video, repo) {- const savedVideo = repo.getVideo(video.id)- if (!savedVideo) return Object.assign(video, {addedAt: Date.now()})- Object.assign(savedVideo, video)- return savedVideo-}\ No newline at end of file