fix(announcement): お知らせ機能の改善・バグ修正 (MisskeyIO#280)
・過去のお知らせでは表示順設定を適用しないように ・過去のお知らせでもわかったボタンが出るように ・お知らせ管理画面では表示順設定を適用しないように ・お知らせ管理画面のページング処理のバグ修正
This commit is contained in:
parent
ba4f9279fb
commit
c31f27e327
|
@ -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<Packed<'Announcement'>[]> {
|
||||
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)
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkTime :time="announcement.updatedAt ?? announcement.createdAt" mode="detail"/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="tab !== 'past' && $i && !announcement.silence && !announcement.isRead" :class="$style.footer">
|
||||
<div v-if="$i && !announcement.silence && !announcement.isRead" :class="$style.footer">
|
||||
<MkButton primary @click="read(announcement)"><i class="ti ti-check"></i> {{ i18n.ts.gotIt }}</MkButton>
|
||||
</div>
|
||||
</section>
|
||||
|
|
Loading…
Reference in a new issue