From 753cef9413a7017363513883131da34f620476e9 Mon Sep 17 00:00:00 2001 From: ssmucny Date: Thu, 20 Apr 2023 20:11:37 -0400 Subject: [PATCH] Add events tab to user details page --- .../api/endpoints/notes/events/search.ts | 16 +++--- packages/frontend/src/components/MkEvent.vue | 4 +- packages/frontend/src/pages/user/events.vue | 50 +++++++++++++++++++ packages/frontend/src/pages/user/index.vue | 8 ++- 4 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 packages/frontend/src/pages/user/events.vue diff --git a/packages/backend/src/server/api/endpoints/notes/events/search.ts b/packages/backend/src/server/api/endpoints/notes/events/search.ts index f286ed808d..7693cf35cc 100644 --- a/packages/backend/src/server/api/endpoints/notes/events/search.ts +++ b/packages/backend/src/server/api/endpoints/notes/events/search.ts @@ -35,7 +35,7 @@ export const meta = { message: 'Invalid Parameter', code: 'INVALID_PARAM', id: 'e70903d3-0aa2-44d5-a955-4de5723c603d', - } + }, }, } as const; @@ -50,7 +50,7 @@ export const paramDef = { nullable: true, description: 'The local host is represented with `null`.', }, - users: { type: 'array', nullable: true, items: { type: 'object', format: 'misskey:id' } }, + users: { type: 'array', nullable: true, items: { type: 'string', format: 'misskey:id' } }, sinceDate: { type: 'integer', nullable: true }, untilDate: { type: 'integer', nullable: true }, filters: { @@ -109,15 +109,19 @@ export default class extends Endpoint { } if (ps.sinceDate && ps.untilDate && ps.sinceDate > ps.untilDate) throw new ApiError(meta.errors.invalidParam); - const sinceDate = ps.sinceDate ? new Date(ps.sinceDate) : new Date(); - query.andWhere('event.start > :sinceDate', { sinceDate: sinceDate }) - .andWhere('(event.end IS NULL OR event.end > :sinceDate)', { sinceDate: sinceDate }); + + if (ps.sinceDate || ps.sortBy !== 'createdAt') { + const sinceDate = ps.sinceDate ? new Date(ps.sinceDate) : new Date(); + query.andWhere('event.start > :sinceDate', { sinceDate: sinceDate }) + .andWhere('(event.end IS NULL OR event.end > :sinceDate)', { sinceDate: sinceDate }); + } + if (ps.untilDate) { query.andWhere('event.start < :untilDate', { untilDate: new Date(ps.untilDate) }); } if (ps.sortBy === 'createdAt') { - query.orderBy('note.createdAt', 'ASC'); + query.orderBy('note.createdAt', 'DESC'); } else { query.orderBy('event.start', 'ASC'); } diff --git a/packages/frontend/src/components/MkEvent.vue b/packages/frontend/src/components/MkEvent.vue index 9fa351dcee..b38986a23c 100644 --- a/packages/frontend/src/components/MkEvent.vue +++ b/packages/frontend/src/components/MkEvent.vue @@ -3,8 +3,8 @@
Start: {{ note.event!.start }}
End: {{ note.event!.end }}
diff --git a/packages/frontend/src/pages/user/events.vue b/packages/frontend/src/pages/user/events.vue new file mode 100644 index 0000000000..3e6ffe1a52 --- /dev/null +++ b/packages/frontend/src/pages/user/events.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/packages/frontend/src/pages/user/index.vue b/packages/frontend/src/pages/user/index.vue index 03a226cc09..1482ecd11b 100644 --- a/packages/frontend/src/pages/user/index.vue +++ b/packages/frontend/src/pages/user/index.vue @@ -5,7 +5,8 @@
- + + @@ -32,6 +33,7 @@ import { $i } from '@/account'; const XHome = defineAsyncComponent(() => import('./home.vue')); const XTimeline = defineAsyncComponent(() => import('./index.timeline.vue')); +const XEvent = defineAsyncComponent(() => import('./events.vue')); const XActivity = defineAsyncComponent(() => import('./activity.vue')); const XAchievements = defineAsyncComponent(() => import('./achievements.vue')); const XReactions = defineAsyncComponent(() => import('./reactions.vue')); @@ -74,6 +76,10 @@ const headerTabs = $computed(() => user ? [{ key: 'notes', title: i18n.ts.notes, icon: 'ti ti-pencil', +}, { + key: 'events', + title: 'Events', //i18n.ts.events, + icon: 'ti ti-calendar', }, { key: 'activity', title: i18n.ts.activity,