fix: notifications spam
This commit is contained in:
parent
02ce8bd5b4
commit
1682132e1c
1 changed files with 18 additions and 8 deletions
|
|
@ -187,9 +187,9 @@ export default class CollesController {
|
||||||
parseFloat(beforeColle.grade)
|
parseFloat(beforeColle.grade)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// if (!deepEqual(beforeColle, afterColle)) {
|
if (hasChanged(beforeColle, afterColle)) {
|
||||||
// await this.notificationService.sendNotification('COLLE_UPDATED', existing)
|
await this.notificationService.sendNotification('COLLE_UPDATED', existing)
|
||||||
// }
|
}
|
||||||
return existing.save()
|
return existing.save()
|
||||||
}
|
}
|
||||||
const colle = await Colle.create(colleData)
|
const colle = await Colle.create(colleData)
|
||||||
|
|
@ -269,9 +269,9 @@ export default class CollesController {
|
||||||
const afterColle = oldColle.serialize()
|
const afterColle = oldColle.serialize()
|
||||||
upcomingCollesIds.delete(oldColle.id)
|
upcomingCollesIds.delete(oldColle.id)
|
||||||
|
|
||||||
if (beforeColle.room !== afterColle.room) {
|
if (beforeColle.roomId !== afterColle.roomId) {
|
||||||
await this.notificationService.sendNotification('ROOM_UPDATED', oldColle)
|
await this.notificationService.sendNotification('ROOM_UPDATED', oldColle)
|
||||||
} else if (!deepEqual(beforeColle, afterColle)) {
|
} else if (hasChanged(beforeColle, afterColle)) {
|
||||||
await this.notificationService.sendNotification('COLLE_UPDATED', oldColle)
|
await this.notificationService.sendNotification('COLLE_UPDATED', oldColle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -298,6 +298,16 @@ export default class CollesController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deepEqual(a: any, b: any) {
|
const propsToCheck = [
|
||||||
return JSON.stringify(a) === JSON.stringify(b)
|
'examinerId',
|
||||||
}
|
'bjsecret',
|
||||||
|
'bjid',
|
||||||
|
'grade',
|
||||||
|
'content',
|
||||||
|
'comment',
|
||||||
|
'roomId',
|
||||||
|
'date',
|
||||||
|
'subjectId',
|
||||||
|
]
|
||||||
|
const hasChanged = (beforeColle: any, afterColle: any) =>
|
||||||
|
propsToCheck.some((prop) => beforeColle[prop] !== afterColle[prop])
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue