-
Notifications
You must be signed in to change notification settings - Fork 512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added notification support for new items being added to a library #3464
base: master
Are you sure you want to change the base?
Changes from 1 commit
aad2d9a
a5ef1d4
9513580
de54982
5aef247
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,8 @@ const LibraryItemScanData = require('./LibraryItemScanData') | |
const Task = require('../objects/Task') | ||
|
||
class LibraryScanner { | ||
constructor() { | ||
constructor(notificationManager) { | ||
this.notificationManager = notificationManager | ||
this.cancelLibraryScan = {} | ||
/** @type {string[]} - library ids */ | ||
this.librariesScanning = [] | ||
|
@@ -284,6 +285,7 @@ class LibraryScanner { | |
'items_added', | ||
newOldLibraryItems.map((li) => li.toJSONExpanded()) | ||
) | ||
this.notificationManager.onItemsAdded(newOldLibraryItems) | ||
newOldLibraryItems = [] | ||
} | ||
|
||
|
@@ -296,6 +298,7 @@ class LibraryScanner { | |
'items_added', | ||
newOldLibraryItems.map((li) => li.toJSONExpanded()) | ||
) | ||
this.notificationManager.onItemsAdded(newOldLibraryItems) | ||
} | ||
} | ||
|
||
|
@@ -647,14 +650,15 @@ class LibraryScanner { | |
if (newLibraryItem) { | ||
const oldNewLibraryItem = Database.libraryItemModel.getOldLibraryItem(newLibraryItem) | ||
SocketAuthority.emitter('item_added', oldNewLibraryItem.toJSONExpanded()) | ||
this.notificationManager.onItemsAdded([oldNewLibraryItem]) | ||
} | ||
itemGroupingResults[itemDir] = newLibraryItem ? ScanResult.ADDED : ScanResult.NOTHING | ||
} | ||
|
||
return itemGroupingResults | ||
} | ||
} | ||
module.exports = new LibraryScanner() | ||
module.exports = new LibraryScanner(new NotificationManager()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The server doesn't run because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated it to a singleton so you can merge master to fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, I ran the server just fine with the new instantiation of |
||
|
||
function ItemToFileInoMatch(libraryItem1, libraryItem2) { | ||
return libraryItem1.isFile && libraryItem2.libraryFiles.some((lf) => lf.ino === libraryItem1.ino) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will want to edit the file in
docs/objects/Notification.yaml
to add the new element to theNotificationEventName
. Thedocs/openapi.json
is automatically generated from those files and should not be edited directly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, whoops. I misread the previous edit, disregard.