aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-10 09:40:20 +0200
committerChocobozzz <me@florianbigard.com>2022-06-10 09:40:20 +0200
commit55269c0460207ebd924fedeeb88fc0bca973b96d (patch)
tree67d2361281daaf18105b44419fe25ab367d8a932 /client/src/app/shared
parent462a833e4c14b84224182adbe9e963535c165ad1 (diff)
downloadPeerTube-55269c0460207ebd924fedeeb88fc0bca973b96d.tar.gz
PeerTube-55269c0460207ebd924fedeeb88fc0bca973b96d.tar.zst
PeerTube-55269c0460207ebd924fedeeb88fc0bca973b96d.zip
Fix search filters count
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-search/advanced-search.model.ts31
1 files changed, 14 insertions, 17 deletions
diff --git a/client/src/app/shared/shared-search/advanced-search.model.ts b/client/src/app/shared/shared-search/advanced-search.model.ts
index e40fd2e66..1375820da 100644
--- a/client/src/app/shared/shared-search/advanced-search.model.ts
+++ b/client/src/app/shared/shared-search/advanced-search.model.ts
@@ -40,9 +40,6 @@ export class AdvancedSearch {
40 searchTarget: SearchTargetType 40 searchTarget: SearchTargetType
41 resultType: AdvancedSearchResultType 41 resultType: AdvancedSearchResultType
42 42
43 // Filters we don't want to count, because they are mandatory
44 private silentFilters = new Set([ 'sort', 'searchTarget' ])
45
46 constructor (options?: { 43 constructor (options?: {
47 startDate?: string 44 startDate?: string
48 endDate?: string 45 endDate?: string
@@ -101,14 +98,7 @@ export class AdvancedSearch {
101 } 98 }
102 99
103 containsValues () { 100 containsValues () {
104 const obj = this.toUrlObject() 101 return this.size() !== 0
105 for (const k of Object.keys(obj)) {
106 if (this.silentFilters.has(k)) continue
107
108 if (this.isValidValue(obj[k])) return true
109 }
110
111 return false
112 } 102 }
113 103
114 reset () { 104 reset () {
@@ -193,12 +183,19 @@ export class AdvancedSearch {
193 size () { 183 size () {
194 let acc = 0 184 let acc = 0
195 185
196 const obj = this.toUrlObject() 186 if (this.isValidValue(this.startDate) || this.isValidValue(this.endDate)) acc++
197 for (const k of Object.keys(obj)) { 187 if (this.isValidValue(this.originallyPublishedStartDate) || this.isValidValue(this.originallyPublishedEndDate)) acc++
198 if (this.silentFilters.has(k)) continue 188
199 189 if (this.isValidValue(this.nsfw)) acc++
200 if (this.isValidValue(obj[k])) acc++ 190 if (this.isValidValue(this.categoryOneOf)) acc++
201 } 191 if (this.isValidValue(this.licenceOneOf)) acc++
192 if (this.isValidValue(this.languageOneOf)) acc++
193 if (this.isValidValue(this.tagsOneOf)) acc++
194 if (this.isValidValue(this.tagsAllOf)) acc++
195 if (this.isValidValue(this.durationMin) || this.isValidValue(this.durationMax)) acc++
196 if (this.isValidValue(this.isLive)) acc++
197 if (this.isValidValue(this.host)) acc++
198 if (this.isValidValue(this.resultType)) acc++
202 199
203 return acc 200 return acc
204 } 201 }