Revert "Extracting sorting modes into its own model"

This reverts commit 839f9fd3f23027bfc00551f22ab0e52c5b63087f.
This commit is contained in:
778a69cd 2023-04-03 13:18:45 +02:00
parent c806a7b3c7
commit 4a04548c1c
2 changed files with 34 additions and 37 deletions

View file

@ -1,19 +0,0 @@
import { EventSortField, SortDirection } from "./enums";
export interface ISorting {
title: string;
orderBy: EventSortField;
direction: SortDirection;
}
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;
}

View file

@ -43,7 +43,15 @@
>
<section class="events-recent">
<h2 class="title">
{{ $t(this.sorting.title) }}
{{
$t(
config &&
config.instanceHomepageSorting ===
InstanceHomepageSorting.UPCOMING
? "Upcoming Events"
: "Last published events"
)
}}
</h2>
<p>
<i18n tag="span" path="On {instance} and other federated instances">
@ -226,7 +234,15 @@
/>
<section class="events-recent">
<h2 class="title">
{{ $t(this.sorting.title) }}
{{
$t(
config &&
config.instanceHomepageSorting ===
InstanceHomepageSorting.UPCOMING
? "Upcoming Events"
: "Last published events"
)
}}
</h2>
<p>
<i18n tag="span" path="On {instance} and other federated instances">
@ -258,7 +274,12 @@
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { InstanceHomepageSorting, ParticipantRole } from "@/types/enums";
import {
EventSortField,
InstanceHomepageSorting,
ParticipantRole,
SortDirection,
} from "@/types/enums";
import { Paginate } from "@/types/paginate";
import { supportsWebPFormat } from "@/utils/support";
import { IParticipant, Participant } from "../types/participant.model";
@ -278,11 +299,6 @@ 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 { IConfig } from "../types/config.model";
import { IFollowedGroupEvent } from "../types/followedGroupEvent.model";
import Subtitle from "../components/Utils/Subtitle.vue";
@ -292,7 +308,16 @@ import Subtitle from "../components/Utils/Subtitle.vue";
events: {
query: FETCH_EVENTS,
variables() {
return this.sorting;
return this.config?.instanceHomepageSorting ===
InstanceHomepageSorting.UPCOMING
? {
orderBy: EventSortField.BEGINS_ON,
direction: SortDirection.ASC,
}
: {
orderBy: EventSortField.INSERTED_AT,
direction: SortDirection.DESC,
};
},
},
currentActor: {
@ -461,15 +486,6 @@ export default class Home extends Vue {
);
}
get sorting(): ISorting {
switch (this.config?.instanceHomepageSorting) {
case InstanceHomepageSorting.UPCOMING:
return new SortingUpcoming();
default:
return new SortingCreated();
}
}
get thisWeekGoingToEvents(): IParticipant[] {
const res = this.currentUserParticipations.filter(
({ event, role }) =>