mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-31 08:14:40 +02:00
Notification create/update events UI
This commit is contained in:
parent
ff04eb8d5e
commit
b08ad8785e
9 changed files with 389 additions and 9 deletions
|
@ -1,3 +1,5 @@
|
|||
const { getId } = require('../utils/index')
|
||||
|
||||
class Notification {
|
||||
constructor(notification = null) {
|
||||
this.id = null
|
||||
|
@ -42,6 +44,37 @@ class Notification {
|
|||
}
|
||||
}
|
||||
|
||||
setData(payload) {
|
||||
this.id = getId('noti')
|
||||
this.libraryId = payload.libraryId || null
|
||||
this.eventName = payload.eventName
|
||||
this.urls = payload.urls
|
||||
this.titleTemplate = payload.titleTemplate
|
||||
this.bodyTemplate = payload.bodyTemplate
|
||||
this.enabled = !!payload.enabled
|
||||
this.type = payload.type || null
|
||||
this.createdAt = Date.now()
|
||||
}
|
||||
|
||||
update(payload) {
|
||||
const keysToUpdate = ['libraryId', 'eventName', 'urls', 'titleTemplate', 'bodyTemplate', 'enabled', 'type']
|
||||
var hasUpdated = false
|
||||
for (const key of keysToUpdate) {
|
||||
if (payload[key]) {
|
||||
if (key === 'urls') {
|
||||
if (payload[key].join(',') !== this.urls.join(',')) {
|
||||
this.urls = [...payload[key]]
|
||||
hasUpdated = true
|
||||
}
|
||||
} else if (payload[key] !== this[key]) {
|
||||
this[key] = payload[key]
|
||||
hasUpdated = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return hasUpdated
|
||||
}
|
||||
|
||||
parseTitleTemplate(data) {
|
||||
// TODO: Implement template parsing
|
||||
return 'Test Title'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue