X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Frest%2Frest.service.ts;h=d8b5ffb1851755aee06a8373a2c035c4cc5bc1d9;hb=0c302acb3c358b4d4d8dee45aed1de1108ea37ea;hp=b2a5a3f72a13cd749111cb6bdcad6bbe3373bd45;hpb=dd6d2a7ce50e7ff02e00995ccc87f8f929ad9709;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/rest/rest.service.ts b/client/src/app/core/rest/rest.service.ts index b2a5a3f72..d8b5ffb18 100644 --- a/client/src/app/core/rest/rest.service.ts +++ b/client/src/app/core/rest/rest.service.ts @@ -5,7 +5,7 @@ import { Injectable } from '@angular/core' import { ComponentPaginationLight } from './component-pagination.model' import { RestPagination } from './rest-pagination' -const logger = debug('peertube:rest') +const debugLogger = debug('peertube:rest') interface QueryStringFilterPrefixes { [key: string]: { @@ -31,19 +31,19 @@ export class RestService { } if (sort !== undefined) { - let sortString = '' + newParams = newParams.set('sort', this.buildSortString(sort)) + } - if (typeof sort === 'string') { - sortString = sort - } else { - const sortPrefix = sort.order === 1 ? '' : '-' - sortString = sortPrefix + sort.field - } + return newParams + } - newParams = newParams.set('sort', sortString) + buildSortString (sort: SortMeta | string) { + if (typeof sort === 'string') { + return sort } - return newParams + const sortPrefix = sort.order === 1 ? '' : '-' + return sortPrefix + sort.field } addArrayParams (params: HttpParams, name: string, values: (string | number)[]) { @@ -88,7 +88,7 @@ export class RestService { const prefixeStrings = Object.values(prefixes) .map(p => p.prefix) - logger(`Built tokens "${tokens.join(', ')}" for prefixes "${prefixeStrings.join(', ')}"`) + debugLogger(`Built tokens "${tokens.join(', ')}" for prefixes "${prefixeStrings.join(', ')}"`) // Search is the querystring minus defined filters const searchTokens = tokens.filter(t => { @@ -127,7 +127,7 @@ export class RestService { const search = searchTokens.join(' ') || undefined - logger('Built search: ' + search, additionalFilters) + debugLogger('Built search: ' + search, additionalFilters) return { search,