mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-27 06:09:38 +00:00
Update NotificationManager to singleton
This commit is contained in:
parent
567a9a4e58
commit
7cd8d7f44d
6 changed files with 16 additions and 20 deletions
|
|
@ -15,13 +15,12 @@ const { getFileSize } = require('../utils/fileUtils')
|
|||
|
||||
const Backup = require('../objects/Backup')
|
||||
const CacheManager = require('./CacheManager')
|
||||
const NotificationManager = require('./NotificationManager')
|
||||
|
||||
class BackupManager {
|
||||
constructor(notificationManager) {
|
||||
constructor() {
|
||||
this.ItemsMetadataPath = Path.join(global.MetadataPath, 'items')
|
||||
this.AuthorsMetadataPath = Path.join(global.MetadataPath, 'authors')
|
||||
/** @type {import('./NotificationManager')} */
|
||||
this.notificationManager = notificationManager
|
||||
|
||||
this.scheduleTask = null
|
||||
|
||||
|
|
@ -301,7 +300,7 @@ class BackupManager {
|
|||
const sqliteBackupPath = await this.backupSqliteDb(newBackup).catch((error) => {
|
||||
Logger.error(`[BackupManager] Failed to backup sqlite db`, error)
|
||||
const errorMsg = error?.message || error || 'Unknown Error'
|
||||
this.notificationManager.onBackupFailed(errorMsg)
|
||||
NotificationManager.onBackupFailed(errorMsg)
|
||||
return false
|
||||
})
|
||||
|
||||
|
|
@ -313,7 +312,7 @@ class BackupManager {
|
|||
const zipResult = await this.zipBackup(sqliteBackupPath, newBackup).catch((error) => {
|
||||
Logger.error(`[BackupManager] Backup Failed ${error}`)
|
||||
const errorMsg = error?.message || error || 'Unknown Error'
|
||||
this.notificationManager.onBackupFailed(errorMsg)
|
||||
NotificationManager.onBackupFailed(errorMsg)
|
||||
return false
|
||||
})
|
||||
|
||||
|
|
@ -344,7 +343,7 @@ class BackupManager {
|
|||
}
|
||||
|
||||
// Notification for backup successfully completed
|
||||
this.notificationManager.onBackupCompleted(newBackup, this.backups.length, removeOldest)
|
||||
NotificationManager.onBackupCompleted(newBackup, this.backups.length, removeOldest)
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,4 +180,4 @@ class NotificationManager {
|
|||
})
|
||||
}
|
||||
}
|
||||
module.exports = NotificationManager
|
||||
module.exports = new NotificationManager()
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ const ffmpegHelpers = require('../utils/ffmpegHelpers')
|
|||
|
||||
const TaskManager = require('./TaskManager')
|
||||
const CoverManager = require('../managers/CoverManager')
|
||||
const NotificationManager = require('../managers/NotificationManager')
|
||||
|
||||
const LibraryFile = require('../objects/files/LibraryFile')
|
||||
const PodcastEpisodeDownload = require('../objects/PodcastEpisodeDownload')
|
||||
|
|
@ -22,9 +23,8 @@ const AudioFile = require('../objects/files/AudioFile')
|
|||
const LibraryItem = require('../objects/LibraryItem')
|
||||
|
||||
class PodcastManager {
|
||||
constructor(watcher, notificationManager) {
|
||||
constructor(watcher) {
|
||||
this.watcher = watcher
|
||||
this.notificationManager = notificationManager
|
||||
|
||||
this.downloadQueue = []
|
||||
this.currentDownload = null
|
||||
|
|
@ -203,7 +203,7 @@ class PodcastManager {
|
|||
|
||||
if (this.currentDownload.isAutoDownload) {
|
||||
// Notifications only for auto downloaded episodes
|
||||
this.notificationManager.onPodcastEpisodeDownloaded(libraryItem, podcastEpisode)
|
||||
NotificationManager.onPodcastEpisodeDownloaded(libraryItem, podcastEpisode)
|
||||
}
|
||||
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue