Improve performance
This commit is contained in:
parent
ffb853bf2d
commit
3693ce9f00
|
@ -61,7 +61,7 @@ export class NotificationEntityService implements OnModuleInit {
|
||||||
meId: MiUser['id'],
|
meId: MiUser['id'],
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
options: {
|
options: {
|
||||||
|
checkValidNotifier?: boolean;
|
||||||
},
|
},
|
||||||
hint?: {
|
hint?: {
|
||||||
packedNotes: Map<MiNote['id'], Packed<'Note'>>;
|
packedNotes: Map<MiNote['id'], Packed<'Note'>>;
|
||||||
|
@ -70,7 +70,7 @@ export class NotificationEntityService implements OnModuleInit {
|
||||||
): Promise<Packed<'Notification'>|null> {
|
): Promise<Packed<'Notification'>|null> {
|
||||||
const notification = src;
|
const notification = src;
|
||||||
|
|
||||||
if (!(await this.#isValidNotifier(notification, meId))) return null;
|
if (options.checkValidNotifier && !(await this.#isValidNotifier(notification, meId))) return null;
|
||||||
|
|
||||||
const noteIfNeed = NOTE_REQUIRED_NOTIFICATION_TYPES.has(notification.type) && 'noteId' in notification ? (
|
const noteIfNeed = NOTE_REQUIRED_NOTIFICATION_TYPES.has(notification.type) && 'noteId' in notification ? (
|
||||||
hint?.packedNotes != null
|
hint?.packedNotes != null
|
||||||
|
@ -149,7 +149,7 @@ export class NotificationEntityService implements OnModuleInit {
|
||||||
validNotifications = validNotifications.filter(x => (x.type !== 'receiveFollowRequest') || reqs.some(r => r.followerId === x.notifierId));
|
validNotifications = validNotifications.filter(x => (x.type !== 'receiveFollowRequest') || reqs.some(r => r.followerId === x.notifierId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (await Promise.all(validNotifications.map(x => this.pack(x, meId, {}, {
|
return (await Promise.all(validNotifications.map(x => this.pack(x, meId, { checkValidNotifier: false }, {
|
||||||
packedNotes,
|
packedNotes,
|
||||||
packedUsers,
|
packedUsers,
|
||||||
})))).filter(isNotNull);
|
})))).filter(isNotNull);
|
||||||
|
@ -290,7 +290,7 @@ export class NotificationEntityService implements OnModuleInit {
|
||||||
validNotifications = validNotifications.filter(x => (x.type !== 'receiveFollowRequest') || reqs.some(r => r.followerId === x.notifierId));
|
validNotifications = validNotifications.filter(x => (x.type !== 'receiveFollowRequest') || reqs.some(r => r.followerId === x.notifierId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (await Promise.all(validNotifications.map(x => this.packGrouped(x, meId, {}, {
|
return (await Promise.all(validNotifications.map(x => this.packGrouped(x, meId, { checkValidNotifier: false }, {
|
||||||
packedNotes,
|
packedNotes,
|
||||||
packedUsers,
|
packedUsers,
|
||||||
})))).filter(isNotNull);
|
})))).filter(isNotNull);
|
||||||
|
|
Loading…
Reference in New Issue