From 807b1084b086a966df3fc7ce2814bf2bfa9796dc Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 29 Oct 2021 10:53:43 +0200 Subject: [PATCH] Show group followed/member events on homepage Signed-off-by: Thomas Citharel --- js/fragmentTypes.json | 74 +++-------- js/src/graphql/home.ts | 107 +++++++++++++++ js/src/types/current-user.model.ts | 2 + js/src/types/followedGroupEvent.model.ts | 10 ++ js/src/views/Home.vue | 159 +++++++++++------------ 5 files changed, 214 insertions(+), 138 deletions(-) create mode 100644 js/src/graphql/home.ts create mode 100644 js/src/types/followedGroupEvent.model.ts diff --git a/js/fragmentTypes.json b/js/fragmentTypes.json index 649592581..2316e34c5 100644 --- a/js/fragmentTypes.json +++ b/js/fragmentTypes.json @@ -5,79 +5,41 @@ "kind": "INTERFACE", "name": "ActionLogObject", "possibleTypes": [ - { - "name": "Comment" - }, - { - "name": "Event" - }, - { - "name": "Person" - }, - { - "name": "Report" - }, - { - "name": "ReportNote" - }, - { - "name": "User" - } + { "name": "Comment" }, + { "name": "Event" }, + { "name": "Group" }, + { "name": "Person" }, + { "name": "Report" }, + { "name": "ReportNote" }, + { "name": "User" } ] }, { "kind": "INTERFACE", "name": "ActivityObject", "possibleTypes": [ - { - "name": "Comment" - }, - { - "name": "Discussion" - }, - { - "name": "Event" - }, - { - "name": "Group" - }, - { - "name": "Member" - }, - { - "name": "Post" - }, - { - "name": "Resource" - } + { "name": "Comment" }, + { "name": "Discussion" }, + { "name": "Event" }, + { "name": "Group" }, + { "name": "Member" }, + { "name": "Post" }, + { "name": "Resource" } ] }, { "kind": "INTERFACE", "name": "Actor", "possibleTypes": [ - { - "name": "Person" - }, - { - "name": "Group" - }, - { - "name": "Application" - } + { "name": "Application" }, + { "name": "Group" }, + { "name": "Person" } ] }, { "kind": "INTERFACE", "name": "Interactable", - "possibleTypes": [ - { - "name": "Event" - }, - { - "name": "Group" - } - ] + "possibleTypes": [{ "name": "Event" }, { "name": "Group" }] } ] } diff --git a/js/src/graphql/home.ts b/js/src/graphql/home.ts new file mode 100644 index 000000000..93cbdcfa4 --- /dev/null +++ b/js/src/graphql/home.ts @@ -0,0 +1,107 @@ +import gql from "graphql-tag"; +import { ACTOR_FRAGMENT } from "./actor"; +import { ADDRESS_FRAGMENT } from "./address"; +import { EVENT_OPTIONS_FRAGMENT } from "./event"; +import { TAG_FRAGMENT } from "./tags"; +import { USER_SETTINGS_FRAGMENT } from "./user"; + +export const HOME_USER_QUERIES = gql` + query HomeUserQueries( + $afterDateTime: DateTime + $beforeDateTime: DateTime + $page: Int + $limit: Int + ) { + loggedUser { + id + locale + settings { + ...UserSettingFragment + } + participations( + afterDatetime: $afterDateTime + beforeDatetime: $beforeDateTime + page: $page + limit: $limit + ) { + total + elements { + event { + id + uuid + title + picture { + id + url + alt + } + beginsOn + visibility + organizerActor { + ...ActorFragment + } + attributedTo { + ...ActorFragment + } + participantStats { + going + notApproved + participant + } + options { + ...EventOptions + } + tags { + ...TagFragment + } + } + id + role + actor { + ...ActorFragment + } + } + } + followGroupEvents { + total + elements { + profile { + id + } + group { + ...ActorFragment + } + event { + id + uuid + title + beginsOn + picture { + url + } + attributedTo { + ...ActorFragment + } + organizerActor { + ...ActorFragment + } + options { + ...EventOptions + } + physicalAddress { + ...AdressFragment + } + tags { + ...TagFragment + } + } + } + } + } + } + ${USER_SETTINGS_FRAGMENT} + ${ADDRESS_FRAGMENT} + ${TAG_FRAGMENT} + ${EVENT_OPTIONS_FRAGMENT} + ${ACTOR_FRAGMENT} +`; diff --git a/js/src/types/current-user.model.ts b/js/src/types/current-user.model.ts index ca752b068..428e36195 100644 --- a/js/src/types/current-user.model.ts +++ b/js/src/types/current-user.model.ts @@ -3,6 +3,7 @@ import type { IPerson } from "@/types/actor/person.model"; import type { Paginate } from "./paginate"; import type { IParticipant } from "./participant.model"; import { ICurrentUserRole, INotificationPendingEnum } from "./enums"; +import { IFollowedGroupEvent } from "./followedGroupEvent.model"; export interface ICurrentUser { id: string; @@ -47,6 +48,7 @@ export interface IUser extends ICurrentUser { drafts: IEvent[]; settings: IUserSettings; activitySettings: IActivitySetting[]; + followedGroupEvents: Paginate; locale: string; provider?: string; lastSignInAt: string; diff --git a/js/src/types/followedGroupEvent.model.ts b/js/src/types/followedGroupEvent.model.ts new file mode 100644 index 000000000..ee80a6ebe --- /dev/null +++ b/js/src/types/followedGroupEvent.model.ts @@ -0,0 +1,10 @@ +import { IEvent } from "./event.model"; +import { IPerson, IGroup } from "./actor"; +import { IUser } from "./current-user.model"; + +export interface IFollowedGroupEvent { + profile: IPerson; + group: IGroup; + user: IUser; + event: IEvent; +} diff --git a/js/src/views/Home.vue b/js/src/views/Home.vue index e51683b7d..6db237f8d 100644 --- a/js/src/views/Home.vue +++ b/js/src/views/Home.vue @@ -1,5 +1,6 @@