Skip to content

Commit

Permalink
Add view to show all tracks on a server
Browse files Browse the repository at this point in the history
This takes advantage of the fact OpenSubsonic specifies that an
empty query should return all tracks. With infinite scrolling, this
means we can just reuse the search controller and have tracks page in as
needed without having a massive download.

This also makes it easy to i.e. download all tracks (fixes GH-147).
  • Loading branch information
NattyNarwhal committed Mar 1, 2025
1 parent 11b9055 commit e14de5f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Doing so isn't fatal (it's not a secret), but it is annoying for other contribut

* Infinite scrolling is added to search results and server albums.
* This enables pulling results beyond the first page of results.
* All tracks on the server can be shown in a new view.
* This can be accessed by Go - By Tracks (Cmd+3).
* Fix album information not getting pulled in from tracks on search.
* Use updated Core Data features for automatic merging of changes between threads.
* This should reduce weirdness such as faults appearing where they shouldn't.
Expand Down
1 change: 1 addition & 0 deletions Submariner/SBDatabaseController.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
- (IBAction)showIndices:(id)sender;
- (IBAction)showAlbums:(id)sender;
- (IBAction)showDirectories:(id)sender;
- (IBAction)showSongs:(id)sender;
- (IBAction)showPodcasts:(id)sender;
- (IBAction)cleanTracklist:(id)sender;
- (IBAction)goToCurrentTrack:(id)sender;
Expand Down
18 changes: 17 additions & 1 deletion Submariner/SBDatabaseController.m
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,15 @@ - (IBAction)showDirectories:(id)sender {
[self navigateForwardToNavItem: navItem];
}

- (IBAction)showSongs:(id)sender {
if (!self.server) {
return;
}
[self.server setSelectedTabIndex: 4];
SBNavigationItem *navItem = [[SBServerSearchNavigationItem alloc] initWithServer: self.server query: @""];
[self navigateForwardToNavItem: navItem];
}

- (IBAction)showPodcasts:(id)sender {
if (!self.server) {
return;
Expand Down Expand Up @@ -1352,6 +1361,9 @@ - (void)displayViewControllerForResource:(SBResource *)resource {
case 3:
navItem = [[SBServerDirectoriesNavigationItem alloc] initWithServer: server];
break;
case 4:
navItem = [[SBServerSearchNavigationItem alloc] initWithServer: server query: @""];
break;
}
} else if([resource isKindOfClass:[SBAlbum class]]) {
SBAlbum *album = (SBAlbum*)resource;
Expand Down Expand Up @@ -1917,7 +1929,11 @@ - (void)pageController:(NSPageController *)pageController didTransitionToObject:
} else if ([navItem isKindOfClass: SBServerSearchNavigationItem.class]) {
SBServerSearchNavigationItem *searchNavItem = (SBServerSearchNavigationItem*)navItem;
// HACK: No sum types in ObjC, see SBNavigationItem
if (searchNavItem.searchQuery) {
if (searchNavItem.searchQuery && [searchNavItem.searchQuery isEqualToString:@""]) {
[self.server searchWithQuery: @""];
[searchField setStringValue: @""];
[searchToolbarItem endSearchInteraction];
} else if (searchNavItem.searchQuery) {
[self.server searchWithQuery: searchNavItem.searchQuery];
[searchField setStringValue: searchNavItem.searchQuery];
} else if (searchNavItem.topTracksForArtist) {
Expand Down
2 changes: 2 additions & 0 deletions Submariner/SBServerSearchController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import Cocoa
@objc dynamic var searchResult: SBSearchResult? {
didSet {
switch self.searchResult?.query {
case .search(query: let query) where query.isEmpty:
self.title = "All Tracks"
case .search(let query):
self.title = "Search Results for \(query)"
case .similarTo(let artist):
Expand Down
13 changes: 9 additions & 4 deletions Submariner/en.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand Down Expand Up @@ -330,12 +330,17 @@ CA
<action selector="showAlbums:" target="494" id="J9l-xR-deB"/>
</connections>
</menuItem>
<menuItem title="By Directories" keyEquivalent="3" id="7L2-8m-bYP">
<menuItem title="By Tracks" keyEquivalent="3" id="RFV-59-ghe">
<connections>
<action selector="showSongs:" target="-1" id="bcY-fY-ct4"/>
</connections>
</menuItem>
<menuItem title="By Directories" keyEquivalent="4" id="7L2-8m-bYP">
<connections>
<action selector="showDirectories:" target="494" id="wSR-kt-g5D"/>
</connections>
</menuItem>
<menuItem title="Podcasts" keyEquivalent="4" id="q8o-ph-bkR">
<menuItem title="Podcasts" keyEquivalent="5" id="q8o-ph-bkR">
<connections>
<action selector="showPodcasts:" target="494" id="hjt-sE-qFb"/>
</connections>
Expand Down

0 comments on commit e14de5f

Please sign in to comment.