diff --git a/modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m b/modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m index aef76be15dbe78b26dc1ea2930b933b24763777a..4eb02f3b213efdf1711eefecf07799915130fa05 100644 --- a/modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m +++ b/modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m @@ -701,11 +701,12 @@ NSString * const VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification return; } + const NSInteger selectedRow = indices.firstIndex; if (tableView.selectedRowIndexes != indices) { [tableView selectRowIndexes:indices byExtendingSelection:NO]; + [tableView scrollRowToVisible:selectedRow]; } - const NSInteger selectedRow = indices.firstIndex; if (selectedRow >= self.displayedCollection.count) { return; } diff --git a/modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m b/modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m index 3c2e17cef1020754d9bf4ce886600c2d4ae2fff1..fbf481d6ab432138a6db19eeaaaba95f06a05e55 100644 --- a/modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m +++ b/modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m @@ -429,8 +429,7 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi const NSInteger rowForLibraryItem = [self.audioDataSource rowForLibraryItem:libraryItem]; if (rowForLibraryItem != NSNotFound) { NSIndexSet * const indexSet = [NSIndexSet indexSetWithIndex:rowForLibraryItem]; - [targetMainTableView selectRowIndexes:indexSet byExtendingSelection:NO]; - [targetMainTableView scrollRowToVisible:rowForLibraryItem]; + [self.audioDataSource tableView:targetMainTableView selectRowIndices:indexSet]; } } @@ -460,7 +459,7 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi } } -- (void)presentLibraryItemWaitForDataSourceFinished:(NSNotification *)aNotification +- (void)presentLibraryItemWaitForDataSourceFinished:(nullable NSNotification *)aNotification { if (self.audioDataSource.displayedCollectionCount < self.audioDataSource.collectionToDisplayCount) { return; @@ -503,12 +502,17 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi segmentType = VLCLibrarySongsMusicSubSegmentType; } + VLCLibraryWindow * const libraryWindow = self.libraryWindow; + if (segmentType == libraryWindow.librarySegmentType) { + [self presentLibraryItemWaitForDataSourceFinished:nil]; + return; + } + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(presentLibraryItemWaitForDataSourceFinished:) name:VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification object:self.audioDataSource]; - VLCLibraryWindow * const libraryWindow = self.libraryWindow; libraryWindow.librarySegmentType = segmentType; [libraryWindow.splitViewController.navSidebarViewController selectSegment:segmentType]; }