Skip to content

Commit

Permalink
Update IndexMethod.php
Browse files Browse the repository at this point in the history
playlist_search and catalogs as browse
  • Loading branch information
lachlan-00 committed May 14, 2024
1 parent 71702d6 commit d49267b
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/Module/Api/Method/IndexMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,35 +97,35 @@ public static function index(array $input, User $user): bool
return false;
}

if ($type == 'catalog') {
$results = User::get_user_catalogs($user->id);
$browse = Api::getBrowse();
$browse->reset_filters();
if (
$type === 'playlist' &&
$hide === false
) {
$browse->set_type('playlist_search');
} elseif ($album_artist) {
$browse->set_type('album_artist');
} elseif ($song_artist) {
$browse->set_type('song_artist');
} else {
$browse = Api::getBrowse();
$browse->reset_filters();
if (
$type === 'playlist' &&
$hide === false
) {
$browse->set_type('playlist_search');
} elseif ($album_artist) {
$browse->set_type('album_artist');
} elseif ($song_artist) {
$browse->set_type('song_artist');
} else {
$browse->set_type($type);
}
$browse->set_sort('name', 'ASC');

$method = (array_key_exists('exact', $input) && (int)$input['exact'] == 1) ? 'exact_match' : 'alpha_match';
Api::set_filter($method, $input['filter'] ?? '', $browse);
Api::set_filter('add', $input['add'] ?? '', $browse);
Api::set_filter('update', $input['update'] ?? '', $browse);
if ($type == 'playlist') {
$browse->set_filter('playlist_type', 1);
}

$results = $browse->get_objects();
$browse->set_type($type);
}

$browse->set_sort('name', 'ASC');
if ($type === 'catalog') {
$browse->set_filter('user', $user->getId());
}

$method = (array_key_exists('exact', $input) && (int)$input['exact'] == 1) ? 'exact_match' : 'alpha_match';
Api::set_filter($method, $input['filter'] ?? '', $browse);
Api::set_filter('add', $input['add'] ?? '', $browse);
Api::set_filter('update', $input['update'] ?? '', $browse);
if ($type == 'playlist') {
$browse->set_filter('playlist_type', 1);
}

$results = $browse->get_objects();
if (empty($results)) {
Api::empty($type, $input['api_format']);

Expand Down

0 comments on commit d49267b

Please sign in to comment.