diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-31 10:41:44 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-31 10:41:44 +0100 |
commit | 61bbc7277501692d1520a421dff5af5d38ba6cf4 (patch) | |
tree | 4c705f7f42f70fc33f5233a4d79b6a6826482cc5 /client/src/app/shared/rest | |
parent | 915c5bbe538769b1d3430b27817d6a861c766ef3 (diff) | |
download | PeerTube-61bbc7277501692d1520a421dff5af5d38ba6cf4.tar.gz PeerTube-61bbc7277501692d1520a421dff5af5d38ba6cf4.tar.zst PeerTube-61bbc7277501692d1520a421dff5af5d38ba6cf4.zip |
Fix human dates in result lists
Diffstat (limited to 'client/src/app/shared/rest')
-rw-r--r-- | client/src/app/shared/rest/rest-extractor.service.ts | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index 1b475da89..ad08a32f8 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { HttpErrorResponse } from '@angular/common/http' | ||
1 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { dateToHuman } from '@app/shared/misc/utils' | ||
2 | import { Observable } from 'rxjs/Observable' | 4 | import { Observable } from 'rxjs/Observable' |
3 | import { HttpErrorResponse } from '@angular/common/http' | ||
4 | |||
5 | import { Utils } from '../utils' | ||
6 | import { ResultList } from '../../../../../shared' | 5 | import { ResultList } from '../../../../../shared' |
7 | 6 | ||
8 | @Injectable() | 7 | @Injectable() |
@@ -16,7 +15,7 @@ export class RestExtractor { | |||
16 | const data: T[] = result.data | 15 | const data: T[] = result.data |
17 | const newData: T[] = [] | 16 | const newData: T[] = [] |
18 | 17 | ||
19 | data.forEach(d => newData.push(fun.call(this, d, additionalArgs))) | 18 | data.forEach(d => newData.push(fun.apply(this, [ d ].concat(additionalArgs)))) |
20 | 19 | ||
21 | return { | 20 | return { |
22 | total: result.total, | 21 | total: result.total, |
@@ -29,12 +28,9 @@ export class RestExtractor { | |||
29 | } | 28 | } |
30 | 29 | ||
31 | convertDateToHuman (target: object, fieldsToConvert: string[]) { | 30 | convertDateToHuman (target: object, fieldsToConvert: string[]) { |
32 | const source = {} | 31 | fieldsToConvert.forEach(field => target[field] = dateToHuman(target[field])) |
33 | fieldsToConvert.forEach(field => { | ||
34 | source[field] = Utils.dateToHuman(target[field]) | ||
35 | }) | ||
36 | 32 | ||
37 | return Object.assign(target, source) | 33 | return target |
38 | } | 34 | } |
39 | 35 | ||
40 | handleError (err: HttpErrorResponse) { | 36 | handleError (err: HttpErrorResponse) { |