mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Only send events to clients who need it
- User events (star, rating, plays) only sent to same user - Don't send to the client (browser window) that originated the event
This commit is contained in:
parent
5f6f74ff2d
commit
b65e76293a
13 changed files with 197 additions and 63 deletions
|
@ -98,7 +98,8 @@ func (s *scanner) rescan(ctx context.Context, mediaFolder string, fullRescan boo
|
|||
if changeCount > 0 {
|
||||
log.Debug(ctx, "Detected changes in the music folder. Sending refresh event",
|
||||
"folder", mediaFolder, "changeCount", changeCount)
|
||||
s.broker.SendMessage(&events.RefreshResource{})
|
||||
// Don't use real context, forcing a refresh in all open windows, including the one that triggered the scan
|
||||
s.broker.SendMessage(context.Background(), &events.RefreshResource{})
|
||||
}
|
||||
|
||||
s.updateLastModifiedSince(mediaFolder, start)
|
||||
|
@ -109,9 +110,9 @@ func (s *scanner) startProgressTracker(mediaFolder string) (chan uint32, context
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
progress := make(chan uint32, 100)
|
||||
go func() {
|
||||
s.broker.SendMessage(&events.ScanStatus{Scanning: true, Count: 0, FolderCount: 0})
|
||||
s.broker.SendMessage(ctx, &events.ScanStatus{Scanning: true, Count: 0, FolderCount: 0})
|
||||
defer func() {
|
||||
s.broker.SendMessage(&events.ScanStatus{
|
||||
s.broker.SendMessage(ctx, &events.ScanStatus{
|
||||
Scanning: false,
|
||||
Count: int64(s.status[mediaFolder].fileCount),
|
||||
FolderCount: int64(s.status[mediaFolder].folderCount),
|
||||
|
@ -126,7 +127,7 @@ func (s *scanner) startProgressTracker(mediaFolder string) (chan uint32, context
|
|||
continue
|
||||
}
|
||||
totalFolders, totalFiles := s.incStatusCounter(mediaFolder, count)
|
||||
s.broker.SendMessage(&events.ScanStatus{
|
||||
s.broker.SendMessage(ctx, &events.ScanStatus{
|
||||
Scanning: true,
|
||||
Count: int64(totalFiles),
|
||||
FolderCount: int64(totalFolders),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue