mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-11-30 12:14:06 +01:00
Update cached user whenever mediaProgress is removed
This commit is contained in:
1 parent
7282afcfde
commit
f1de307bf9
2 files changed
+18
No files matched your search
@@ -126,6 +126,16 @@ class MediaProgress extends Model {
|
||||
}
|
||||
})
|
||||
|
||||
// make sure to call the afterDestroy hook for each instance
|
||||
MediaProgress.addHook('beforeBulkDestroy', (options) => {
|
||||
options.individualHooks = true
|
||||
})
|
||||
|
||||
// update the potentially cached user after destroying the media progress
|
||||
MediaProgress.addHook('afterDestroy', (instance) => {
|
||||
user.mediaProgressRemoved(instance)
|
||||
})
|
||||
|
||||
user.hasMany(MediaProgress, {
|
||||
onDelete: 'CASCADE'
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user