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/itemComparators.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'viewer/src/services/itemComparators.ts') diff --git a/viewer/src/services/itemComparators.ts b/viewer/src/services/itemComparators.ts index bd9accb..aceff79 100644 --- a/viewer/src/services/itemComparators.ts +++ b/viewer/src/services/itemComparators.ts @@ -16,14 +16,15 @@ -- You should have received a copy of the GNU Affero General Public License -- along with this program. If not, see . */ -import { TranslateResult } from "vue-i18n"; +import { Item, ItemSortStr } from "@/@types/gallery"; import i18n from "@/plugins/i18n"; +import { TranslateResult } from "vue-i18n"; -export type ItemComparator = (left: Gallery.Item, right: Gallery.Item) => number; +export type ItemComparator = (left: Item, right: Item) => number; export type ItemSort = { text: TranslateResult; fn: ItemComparator }; export default class ItemComparators { - static readonly ITEM_SORTS: Record = { + static readonly ITEM_SORTS: Record = { title_asc: { text: i18n.t("command.sort.byTitleAsc"), fn: ItemComparators.chain(ItemComparators.sortByTitleAsc, ItemComparators.sortByPathAsc), @@ -40,7 +41,7 @@ export default class ItemComparators { static readonly DEFAULT = ItemComparators.ITEM_SORTS.date_asc; - static sortByPathAsc(left: Gallery.Item, right: Gallery.Item): number { + static sortByPathAsc(left: Item, right: Item): number { return left.path.localeCompare(right.path, undefined, { sensitivity: "base", ignorePunctuation: true, @@ -48,7 +49,7 @@ export default class ItemComparators { }); } - static sortByTitleAsc(left: Gallery.Item, right: Gallery.Item): number { + static sortByTitleAsc(left: Item, right: Item): number { return left.title.localeCompare(right.title, undefined, { sensitivity: "base", ignorePunctuation: true, @@ -56,7 +57,7 @@ export default class ItemComparators { }); } - static sortByDateAsc(left: Gallery.Item, right: Gallery.Item): number { + static sortByDateAsc(left: Item, right: Item): number { return left.datetime.localeCompare(right.datetime); // TODO: handle timezones } -- cgit v1.2.3