Skip to content

armgit / my-yt

Public Imported from GitHub
0

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

JavaScript

refactor: rename to excluded query param

Christian Fei81ebcef77c54
diff --git a/client/components/search-videos.js b/client/components/search-videos.js
index 65ef14b..6b8c267 100644
--- a/client/components/search-videos.js
+++ b/client/components/search-videos.js
@@ -29,7 +29,7 @@ class SearchVideos extends HTMLElement {
this.innerHTML = /*html*/`
<input type="search" incremental="incremental" id="search" placeholder="🔍 Search videos or paste video url" autofocus>
<div>
- <label for="with-excluded">Show excluded videos</label>
+ <label for="with-excluded">Search excluded videos</label>
<input type="checkbox" id="with-excluded"/>
</div>
`
@@ -60,7 +60,7 @@ class SearchVideos extends HTMLElement {
document.body.classList.add('searching')
let withExcluded = this.querySelector('#with-excluded').checked
- fetch(`/api/videos?filter=${encodeURIComponent(searchTerm)}${withExcluded ? '&withExcluded=true' : ''}`)
+ fetch(`/api/videos?filter=${encodeURIComponent(searchTerm)}${withExcluded ? '&excluded=true' : ''}`)
.then(res => res.json())
.then((videos) => {
const $videosContainer = document.querySelector('.main-videos-container')
diff --git a/lib/repository.js b/lib/repository.js
index 7f7ce15..b6815d3 100644
--- a/lib/repository.js
+++ b/lib/repository.js
@@ -76,7 +76,7 @@ export default class Repository {
getVideos (query = {}) {
const isFiltering = Object.keys(query).length > 0 && query.filter
let videos = this.videos
- .filter(v => query.withExcluded === 'true' ? true : this.filterByExcludedTerms(v))
+ .filter(v => query.excluded === 'true' ? true : this.filterByExcludedTerms(v))
.filter(v => isFiltering ? true : !v.ignored)
.sort((a, b) => +new Date(b.publishedAt) - +new Date(a.publishedAt))