From 9165cc1efcf7791f78b61b2c51a9de651b1b09aa Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 2 Jul 2021 22:53:16 +0200 Subject: viewer: types normalization - gallery.d.ts GitHub: closes #301 --- viewer/src/services/indexsearch.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'viewer/src/services/indexsearch.ts') diff --git a/viewer/src/services/indexsearch.ts b/viewer/src/services/indexsearch.ts index 00f8cfc..eda1b27 100644 --- a/viewer/src/services/indexsearch.ts +++ b/viewer/src/services/indexsearch.ts @@ -17,11 +17,12 @@ -- along with this program. If not, see . */ +import { Item } from "@/@types/gallery"; import { Operation } from "@/@types/Operation"; export default class IndexSearch { // Results of the search (by tags) - public static search(searchTags: Tag.Search[]): Gallery.Item[] { + public static search(searchTags: Tag.Search[]): Item[] { const byOperation = this.extractTagsByOperation(searchTags); const intersection = this.extractIntersection(byOperation); const substraction = this.extractSubstraction(byOperation); @@ -36,8 +37,8 @@ export default class IndexSearch { return byOperation; } - private static extractIntersection(byOperation: Tag.SearchByOperation): Set { - const intersection = new Set(); + private static extractIntersection(byOperation: Tag.SearchByOperation): Set { + const intersection = new Set(); if (byOperation[Operation.INTERSECTION].length > 0) { byOperation[Operation.INTERSECTION] .map(tag => tag.items) @@ -48,8 +49,8 @@ export default class IndexSearch { return intersection; } - private static extractSubstraction(byOperation: Tag.SearchByOperation): Set { - const substraction = new Set(); + private static extractSubstraction(byOperation: Tag.SearchByOperation): Set { + const substraction = new Set(); if (byOperation[Operation.SUBSTRACTION].length > 0) { byOperation[Operation.SUBSTRACTION].flatMap(tag => tag.items).forEach(item => substraction.add(item)); } @@ -58,9 +59,9 @@ export default class IndexSearch { private static aggregateAll( byOperation: Tag.SearchByOperation, - intersection: Set, - substraction: Set - ): Gallery.Item[] { + intersection: Set, + substraction: Set + ): Item[] { byOperation[Operation.ADDITION].flatMap(tag => tag.items).forEach(item => intersection.add(item)); substraction.forEach(item => intersection.delete(item)); return [...intersection]; -- cgit v1.2.3