From 4beda9e12adc7b1f3b178cecd6863ebf3cf431f1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 19 Oct 2021 09:44:43 +0200 Subject: Add ability to view my followers --- client/src/app/core/rest/rest.service.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'client/src/app/core/rest/rest.service.ts') 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 { } } -type ParseQueryStringFilterResult = { - [key: string]: string | number | boolean | (string | number | boolean)[] -} +type ParseQueryStringFilters = Partial> +type ParseQueryStringFiltersResult = ParseQueryStringFilters & { search?: string } @Injectable() export class RestService { @@ -67,14 +66,17 @@ export class RestService { return params } - componentPaginationToRestPagination (componentPagination: ComponentPaginationLight): RestPagination { + componentToRestPagination (componentPagination: ComponentPaginationLight): RestPagination { const start: number = (componentPagination.currentPage - 1) * componentPagination.itemsPerPage const count: number = componentPagination.itemsPerPage return { start, count } } - parseQueryStringFilter (q: string, prefixes: QueryStringFilterPrefixes): ParseQueryStringFilterResult { + /* + * Returns an object containing the filters and the remaining search + */ + parseQueryStringFilter (q: string, prefixes: T): ParseQueryStringFiltersResult { if (!q) return {} // Tokenize the strings using spaces that are not in quotes @@ -90,9 +92,9 @@ export class RestService { return prefixeStrings.every(prefixString => t.startsWith(prefixString) === false) }) - const additionalFilters: ParseQueryStringFilterResult = {} + const additionalFilters: ParseQueryStringFilters = {} - for (const prefixKey of Object.keys(prefixes)) { + for (const prefixKey of Object.keys(prefixes) as (keyof T)[]) { const prefixObj = prefixes[prefixKey] const prefix = prefixObj.prefix -- cgit v1.2.3