aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/rest
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-19 09:44:43 +0200
committerChocobozzz <me@florianbigard.com>2021-10-20 09:25:44 +0200
commit4beda9e12adc7b1f3b178cecd6863ebf3cf431f1 (patch)
tree6244a10b286d66c6dcd7799aee630670d0493781 /client/src/app/core/rest
parent9593a78ae1368a9ad8bb11044fce6fde2892701a (diff)
downloadPeerTube-4beda9e12adc7b1f3b178cecd6863ebf3cf431f1.tar.gz
PeerTube-4beda9e12adc7b1f3b178cecd6863ebf3cf431f1.tar.zst
PeerTube-4beda9e12adc7b1f3b178cecd6863ebf3cf431f1.zip
Add ability to view my followers
Diffstat (limited to 'client/src/app/core/rest')
-rw-r--r--client/src/app/core/rest/rest.service.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/client/src/app/core/rest/rest.service.ts b/client/src/app/core/rest/rest.service.ts
index 98e45ffc0..93b5f56b2 100644
--- a/client/src/app/core/rest/rest.service.ts
+++ b/client/src/app/core/rest/rest.service.ts
@@ -13,9 +13,8 @@ interface QueryStringFilterPrefixes {
13 } 13 }
14} 14}
15 15
16type ParseQueryStringFilterResult = { 16type ParseQueryStringFilters <K extends keyof any> = Partial<Record<K, string | number | boolean | (string | number | boolean)[]>>
17 [key: string]: string | number | boolean | (string | number | boolean)[] 17type ParseQueryStringFiltersResult <K extends keyof any> = ParseQueryStringFilters<K> & { search?: string }
18}
19 18
20@Injectable() 19@Injectable()
21export class RestService { 20export class RestService {
@@ -67,14 +66,17 @@ export class RestService {
67 return params 66 return params
68 } 67 }
69 68
70 componentPaginationToRestPagination (componentPagination: ComponentPaginationLight): RestPagination { 69 componentToRestPagination (componentPagination: ComponentPaginationLight): RestPagination {
71 const start: number = (componentPagination.currentPage - 1) * componentPagination.itemsPerPage 70 const start: number = (componentPagination.currentPage - 1) * componentPagination.itemsPerPage
72 const count: number = componentPagination.itemsPerPage 71 const count: number = componentPagination.itemsPerPage
73 72
74 return { start, count } 73 return { start, count }
75 } 74 }
76 75
77 parseQueryStringFilter (q: string, prefixes: QueryStringFilterPrefixes): ParseQueryStringFilterResult { 76 /*
77 * Returns an object containing the filters and the remaining search
78 */
79 parseQueryStringFilter <T extends QueryStringFilterPrefixes> (q: string, prefixes: T): ParseQueryStringFiltersResult<keyof T> {
78 if (!q) return {} 80 if (!q) return {}
79 81
80 // Tokenize the strings using spaces that are not in quotes 82 // Tokenize the strings using spaces that are not in quotes
@@ -90,9 +92,9 @@ export class RestService {
90 return prefixeStrings.every(prefixString => t.startsWith(prefixString) === false) 92 return prefixeStrings.every(prefixString => t.startsWith(prefixString) === false)
91 }) 93 })
92 94
93 const additionalFilters: ParseQueryStringFilterResult = {} 95 const additionalFilters: ParseQueryStringFilters<keyof T> = {}
94 96
95 for (const prefixKey of Object.keys(prefixes)) { 97 for (const prefixKey of Object.keys(prefixes) as (keyof T)[]) {
96 const prefixObj = prefixes[prefixKey] 98 const prefixObj = prefixes[prefixKey]
97 const prefix = prefixObj.prefix 99 const prefix = prefixObj.prefix
98 100