diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-02 15:29:09 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-02 15:40:09 +0200 |
commit | 3da38d6e9f8d600476be276666ac7223aa5f172c (patch) | |
tree | daec25cccb900a0f90fc9d2273099683b42d8551 /client/src/app/core/rest/rest.service.ts | |
parent | 200eaf5152ca72fe6b05a49caf819e22bd045b37 (diff) | |
download | PeerTube-3da38d6e9f8d600476be276666ac7223aa5f172c.tar.gz PeerTube-3da38d6e9f8d600476be276666ac7223aa5f172c.tar.zst PeerTube-3da38d6e9f8d600476be276666ac7223aa5f172c.zip |
Fetch things in bulk for the homepage
Diffstat (limited to 'client/src/app/core/rest/rest.service.ts')
-rw-r--r-- | client/src/app/core/rest/rest.service.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/client/src/app/core/rest/rest.service.ts b/client/src/app/core/rest/rest.service.ts index 1696e6709..98e45ffc0 100644 --- a/client/src/app/core/rest/rest.service.ts +++ b/client/src/app/core/rest/rest.service.ts | |||
@@ -44,13 +44,21 @@ export class RestService { | |||
44 | return newParams | 44 | return newParams |
45 | } | 45 | } |
46 | 46 | ||
47 | addArrayParams (params: HttpParams, name: string, values: (string | number)[]) { | ||
48 | for (const v of values) { | ||
49 | params = params.append(name, v) | ||
50 | } | ||
51 | |||
52 | return params | ||
53 | } | ||
54 | |||
47 | addObjectParams (params: HttpParams, object: { [ name: string ]: any }) { | 55 | addObjectParams (params: HttpParams, object: { [ name: string ]: any }) { |
48 | for (const name of Object.keys(object)) { | 56 | for (const name of Object.keys(object)) { |
49 | const value = object[name] | 57 | const value = object[name] |
50 | if (value === undefined || value === null) continue | 58 | if (value === undefined || value === null) continue |
51 | 59 | ||
52 | if (Array.isArray(value)) { | 60 | if (Array.isArray(value)) { |
53 | for (const v of value) params = params.append(name, v) | 61 | params = this.addArrayParams(params, name, value) |
54 | } else { | 62 | } else { |
55 | params = params.append(name, value) | 63 | params = params.append(name, value) |
56 | } | 64 | } |