mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-26 18:59:25 +02:00
Update:Refactor socket connection management into SocketAuthority
This commit is contained in:
parent
42e68edc65
commit
e2af33e136
22 changed files with 386 additions and 341 deletions
|
@ -2,6 +2,7 @@ const Path = require('path')
|
|||
const fs = require('../libs/fsExtra')
|
||||
const filePerms = require('../utils/filePerms')
|
||||
const Logger = require('../Logger')
|
||||
const SocketAuthority = require('../SocketAuthority')
|
||||
const Library = require('../objects/Library')
|
||||
const libraryHelpers = require('../utils/libraryHelpers')
|
||||
const { sort, createNewSortInstance } = require('../libs/fastSort')
|
||||
|
@ -43,7 +44,7 @@ class LibraryController {
|
|||
library.setData(newLibraryPayload)
|
||||
await this.db.insertEntity('library', library)
|
||||
// TODO: Only emit to users that have access
|
||||
this.emitter('library_added', library.toJSON())
|
||||
SocketAuthority.emitter('library_added', library.toJSON())
|
||||
|
||||
// Add library watcher
|
||||
this.watcher.addLibrary(library)
|
||||
|
@ -120,7 +121,7 @@ class LibraryController {
|
|||
}
|
||||
}
|
||||
await this.db.updateEntity('library', library)
|
||||
this.emitter('library_updated', library.toJSON())
|
||||
SocketAuthority.emitter('library_updated', library.toJSON())
|
||||
}
|
||||
return res.json(library.toJSON())
|
||||
}
|
||||
|
@ -147,7 +148,7 @@ class LibraryController {
|
|||
|
||||
var libraryJson = library.toJSON()
|
||||
await this.db.removeEntity('library', library.id)
|
||||
this.emitter('library_removed', libraryJson)
|
||||
SocketAuthority.emitter('library_removed', libraryJson)
|
||||
return res.json(libraryJson)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue