mirror of
https://github.com/MisskeyIO/misskey
synced 2024-12-19 09:08:19 +09:00
fix(announcement): お知らせ機能の改善・バグ修正 (MisskeyIO#280)
・過去のお知らせでは表示順設定を適用しないように ・過去のお知らせでもわかったボタンが出るように ・お知らせ管理画面では表示順設定を適用しないように ・お知らせ管理画面のページング処理のバグ修正
This commit is contained in:
parent
ba4f9279fb
commit
c31f27e327
@ -140,6 +140,7 @@ export class AnnouncementService {
|
|||||||
moderator: MiUser,
|
moderator: MiUser,
|
||||||
): Promise<(MiAnnouncement & { userInfo: Packed<'UserLite'> | null, reads: number })[]> {
|
): Promise<(MiAnnouncement & { userInfo: Packed<'UserLite'> | null, reads: number })[]> {
|
||||||
const query = this.announcementsRepository.createQueryBuilder('announcement');
|
const query = this.announcementsRepository.createQueryBuilder('announcement');
|
||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
query.andWhere('announcement."userId" = :userId', { userId: userId });
|
query.andWhere('announcement."userId" = :userId', { userId: userId });
|
||||||
} else {
|
} else {
|
||||||
@ -148,7 +149,6 @@ export class AnnouncementService {
|
|||||||
|
|
||||||
query.orderBy({
|
query.orderBy({
|
||||||
'announcement."isActive"': 'DESC',
|
'announcement."isActive"': 'DESC',
|
||||||
'announcement."displayOrder"': 'DESC',
|
|
||||||
'announcement.id': 'DESC',
|
'announcement.id': 'DESC',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -259,9 +259,10 @@ export class AnnouncementService {
|
|||||||
me: MiUser | null,
|
me: MiUser | null,
|
||||||
limit: number,
|
limit: number,
|
||||||
offset: number,
|
offset: number,
|
||||||
isActive?: boolean,
|
isActive: boolean,
|
||||||
): Promise<Packed<'Announcement'>[]> {
|
): Promise<Packed<'Announcement'>[]> {
|
||||||
const query = this.announcementsRepository.createQueryBuilder('announcement');
|
const query = this.announcementsRepository.createQueryBuilder('announcement');
|
||||||
|
|
||||||
if (me) {
|
if (me) {
|
||||||
query.leftJoin(
|
query.leftJoin(
|
||||||
MiAnnouncementRead,
|
MiAnnouncementRead,
|
||||||
@ -295,17 +296,21 @@ export class AnnouncementService {
|
|||||||
query.andWhere('announcement."forExistingUsers" = false');
|
query.andWhere('announcement."forExistingUsers" = false');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isActive !== undefined) {
|
|
||||||
query.andWhere('announcement."isActive" = :isActive', {
|
query.andWhere('announcement."isActive" = :isActive', {
|
||||||
isActive: isActive,
|
isActive: isActive,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
if (isActive) {
|
||||||
query.orderBy({
|
query.orderBy({
|
||||||
'"isRead"': 'ASC',
|
'"isRead"': 'ASC',
|
||||||
'announcement."displayOrder"': 'DESC',
|
'announcement."displayOrder"': 'DESC',
|
||||||
'announcement.id': 'DESC',
|
'announcement.id': 'DESC',
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
query.orderBy({
|
||||||
|
'announcement.id': 'DESC',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return this.announcementEntityService.packMany(
|
return this.announcementEntityService.packMany(
|
||||||
await query
|
await query
|
||||||
|
@ -193,7 +193,7 @@ function fetch(resetOffset = false): void {
|
|||||||
}).then(announcementResponse => {
|
}).then(announcementResponse => {
|
||||||
announcements = announcements.concat(announcementResponse);
|
announcements = announcements.concat(announcementResponse);
|
||||||
hasMore.value = announcementResponse?.length === 10;
|
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"/>
|
<MkTime :time="announcement.updatedAt ?? announcement.createdAt" mode="detail"/>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
<MkButton primary @click="read(announcement)"><i class="ti ti-check"></i> {{ i18n.ts.gotIt }}</MkButton>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
Reference in New Issue
Block a user