From 19561da63daad73d301d5127d8628c2e9ca252a3 Mon Sep 17 00:00:00 2001 From: Luca Eichler Date: Sun, 22 Aug 2021 18:33:29 +0200 Subject: [PATCH] Changed interface to consts (cherry picked from commit 238f4f28a31944f98feddedf5fa24714c4328ebc) upstream PR is https://framagit.org/framasoft/mobilizon/-/merge_requests/1236 --- js/src/types/sorting.model.ts | 26 ++++++++++---------------- js/src/views/Home.vue | 12 ++++-------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/js/src/types/sorting.model.ts b/js/src/types/sorting.model.ts index 57271875c..86b76c721 100644 --- a/js/src/types/sorting.model.ts +++ b/js/src/types/sorting.model.ts @@ -1,19 +1,13 @@ import { EventSortField, SortDirection } from "./enums"; -export interface ISorting { - title: string; - orderBy: EventSortField; - direction: SortDirection; -} +export const SORTING_UPCOMING = { + title: "Upcoming Events", + orderBy: EventSortField.BEGINS_ON, + direction: SortDirection.ASC, +}; -export class SortingUpcoming implements ISorting { - title = "Upcoming Events"; - orderBy = EventSortField.BEGINS_ON; - direction = SortDirection.ASC; -} - -export class SortingCreated implements ISorting { - title = "Recently created Events"; - orderBy = EventSortField.INSERTED_AT; - direction = SortDirection.DESC; -} +export const SORTING_CREATED = { + title: "Recently created Events", + orderBy: EventSortField.INSERTED_AT, + direction: SortDirection.DESC, +}; diff --git a/js/src/views/Home.vue b/js/src/views/Home.vue index bead7cfef..074d3affc 100644 --- a/js/src/views/Home.vue +++ b/js/src/views/Home.vue @@ -278,11 +278,7 @@ import RouteName from "../router/name"; import { IEvent } from "../types/event.model"; import DateComponent from "../components/Event/DateCalendarIcon.vue"; import { CONFIG } from "../graphql/config"; -import { - ISorting, - SortingCreated, - SortingUpcoming, -} from "../types/sorting.model"; +import { SORTING_UPCOMING, SORTING_CREATED } from "../types/sorting.model"; import { IConfig } from "../types/config.model"; import { IFollowedGroupEvent } from "../types/followedGroupEvent.model"; import Subtitle from "../components/Utils/Subtitle.vue"; @@ -461,12 +457,12 @@ export default class Home extends Vue { ); } - get sorting(): ISorting { + get sorting() { switch (this.config?.instanceHomepageSorting) { case InstanceHomepageSorting.UPCOMING: - return new SortingUpcoming(); + return SORTING_UPCOMING; default: - return new SortingCreated(); + return SORTING_CREATED; } }