From c31f27e327eea20bf0feefd761a3187295bea7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Thu, 7 Dec 2023 08:46:58 +0900 Subject: [PATCH] =?UTF-8?q?fix(announcement):=20=E3=81=8A=E7=9F=A5?= =?UTF-8?q?=E3=82=89=E3=81=9B=E6=A9=9F=E8=83=BD=E3=81=AE=E6=94=B9=E5=96=84?= =?UTF-8?q?=E3=83=BB=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3=20(MisskeyIO#280)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ・過去のお知らせでは表示順設定を適用しないように ・過去のお知らせでもわかったボタンが出るように ・お知らせ管理画面では表示順設定を適用しないように ・お知らせ管理画面のページング処理のバグ修正 --- .../backend/src/core/AnnouncementService.ts | 27 +++++++++++-------- .../src/pages/admin/announcements.vue | 2 +- packages/frontend/src/pages/announcements.vue | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/backend/src/core/AnnouncementService.ts b/packages/backend/src/core/AnnouncementService.ts index 58b07bef9a..45d6a5fcde 100644 --- a/packages/backend/src/core/AnnouncementService.ts +++ b/packages/backend/src/core/AnnouncementService.ts @@ -140,6 +140,7 @@ export class AnnouncementService { moderator: MiUser, ): Promise<(MiAnnouncement & { userInfo: Packed<'UserLite'> | null, reads: number })[]> { const query = this.announcementsRepository.createQueryBuilder('announcement'); + if (userId) { query.andWhere('announcement."userId" = :userId', { userId: userId }); } else { @@ -148,7 +149,6 @@ export class AnnouncementService { query.orderBy({ 'announcement."isActive"': 'DESC', - 'announcement."displayOrder"': 'DESC', 'announcement.id': 'DESC', }); @@ -259,9 +259,10 @@ export class AnnouncementService { me: MiUser | null, limit: number, offset: number, - isActive?: boolean, + isActive: boolean, ): Promise[]> { const query = this.announcementsRepository.createQueryBuilder('announcement'); + if (me) { query.leftJoin( MiAnnouncementRead, @@ -295,18 +296,22 @@ export class AnnouncementService { query.andWhere('announcement."forExistingUsers" = false'); } - if (isActive !== undefined) { - query.andWhere('announcement."isActive" = :isActive', { - isActive: isActive, + query.andWhere('announcement."isActive" = :isActive', { + isActive: isActive, + }); + + if (isActive) { + query.orderBy({ + '"isRead"': 'ASC', + 'announcement."displayOrder"': 'DESC', + 'announcement.id': 'DESC', + }); + } else { + query.orderBy({ + 'announcement.id': 'DESC', }); } - query.orderBy({ - '"isRead"': 'ASC', - 'announcement."displayOrder"': 'DESC', - 'announcement.id': 'DESC', - }); - return this.announcementEntityService.packMany( await query .limit(limit) diff --git a/packages/frontend/src/pages/admin/announcements.vue b/packages/frontend/src/pages/admin/announcements.vue index 0fd52c72d1..fdc62d69c8 100644 --- a/packages/frontend/src/pages/admin/announcements.vue +++ b/packages/frontend/src/pages/admin/announcements.vue @@ -193,7 +193,7 @@ function fetch(resetOffset = false): void { }).then(announcementResponse => { announcements = announcements.concat(announcementResponse); hasMore.value = announcementResponse?.length === 10; - offset.value += announcements.length; + offset.value += announcementResponse?.length ?? 0; }); } diff --git a/packages/frontend/src/pages/announcements.vue b/packages/frontend/src/pages/announcements.vue index eebd4f19a8..1158775e24 100644 --- a/packages/frontend/src/pages/announcements.vue +++ b/packages/frontend/src/pages/announcements.vue @@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only -
+
{{ i18n.ts.gotIt }}