Skip to content

Commit

Permalink
check state before hide_dupe_searches
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlan-00 committed May 14, 2024
1 parent 9e0b53b commit 949d65a
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 12 deletions.
11 changes: 9 additions & 2 deletions src/Module/Api/Json4_Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,10 @@ public static function playlists($playlists, $user, $songs = false): string
*/
if ((int)$playlist_id === 0) {
$playlist = new Search((int) str_replace('smart_', '', (string) $playlist_id), 'song', $user);
if ($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names)) {
if (
$playlist->isNew() ||
($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names))
) {
continue;
}
$object_type = 'search';
Expand All @@ -475,7 +478,11 @@ public static function playlists($playlists, $user, $songs = false): string
$object_type = 'playlist';
$art_url = Art::url($playlist_id, $object_type, Core::get_request('auth'));
$playitem_total = $playlist->get_media_count('song');
if ($hide_dupe_searches && $playlist->user == $user->getId()) {
if (
$playlist->isNew() === false &&
$hide_dupe_searches &&
$playlist->user == $user->getId()
) {
$playlist_names[] = $playlist->name;
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/Module/Api/Json5_Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,10 @@ public static function playlists($playlists, $user, $songs = false, $object = tr
*/
if ((int)$playlist_id === 0) {
$playlist = new Search((int) str_replace('smart_', '', (string) $playlist_id), 'song', $user);
if ($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names)) {
if (
$playlist->isNew() ||
($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names))
) {
continue;
}
$object_type = 'search';
Expand All @@ -568,7 +571,11 @@ public static function playlists($playlists, $user, $songs = false, $object = tr
$object_type = 'playlist';
$art_url = Art::url($playlist_id, $object_type, Core::get_request('auth'));
$playitem_total = $playlist->get_media_count('song');
if ($hide_dupe_searches && $playlist->user == $user->getId()) {
if (
$playlist->isNew() === false &&
$hide_dupe_searches &&
$playlist->user == $user->getId()
) {
$playlist_names[] = $playlist->name;
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/Module/Api/Json_Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,10 @@ public static function playlists($objects, $user, $songs = false, $encode = true
*/
if ((int)$playlist_id === 0) {
$playlist = new Search((int) str_replace('smart_', '', (string)$playlist_id), 'song', $user);
if ($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names)) {
if (
$playlist->isNew() ||
($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names))
) {
continue;
}
$object_type = 'search';
Expand All @@ -889,10 +892,17 @@ public static function playlists($objects, $user, $songs = false, $encode = true
$object_type = 'playlist';
$art_url = Art::url($playlist_id, $object_type, Core::get_request('auth'));
$playitem_total = $playlist->get_media_count('song');
if ($hide_dupe_searches && $playlist->user == $user->getId()) {
if (
$playlist->isNew() === false &&
$hide_dupe_searches &&
$playlist->user == $user->getId()
) {
$playlist_names[] = $playlist->name;
}
}
if ($playlist->isNew()) {
continue;
}
$playlist_name = $playlist->get_fullname();
$playlist_user = $playlist->username;
$playlist_type = $playlist->type;
Expand Down
11 changes: 9 additions & 2 deletions src/Module/Api/Xml4_Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,10 @@ public static function playlists($playlists, $user): string
*/
if ((int)$playlist_id === 0) {
$playlist = new Search((int) str_replace('smart_', '', (string) $playlist_id), 'song', $user);
if ($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names)) {
if (
$playlist->isNew() ||
($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names))
) {
continue;
}
$object_type = 'search';
Expand All @@ -557,7 +560,11 @@ public static function playlists($playlists, $user): string
$object_type = 'playlist';
$art_url = Art::url($playlist_id, $object_type, Core::get_request('auth'));
$playitem_total = $playlist->get_media_count('song');
if ($hide_dupe_searches && $playlist->user == $user->getId()) {
if (
$playlist->isNew() === false &&
$hide_dupe_searches &&
$playlist->user == $user->getId()
) {
$playlist_names[] = $playlist->name;
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/Module/Api/Xml5_Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,10 @@ public static function playlists($playlists, $user): string
*/
if ((int)$playlist_id === 0) {
$playlist = new Search((int) str_replace('smart_', '', (string) $playlist_id), 'song', $user);
if ($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names)) {
if (
$playlist->isNew() ||
($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names))
) {
continue;
}
$object_type = 'search';
Expand All @@ -662,7 +665,11 @@ public static function playlists($playlists, $user): string
$object_type = 'playlist';
$art_url = Art::url($playlist_id, $object_type, Core::get_request('auth'));
$playitem_total = $playlist->get_media_count('song');
if ($hide_dupe_searches && $playlist->user == $user->getId()) {
if (
$playlist->isNew() === false &&
$hide_dupe_searches &&
$playlist->user == $user->getId()
) {
$playlist_names[] = $playlist->name;
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/Module/Api/Xml_Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,10 @@ public static function playlists($playlists, $user, $songs = false): string
*/
if ((int)$playlist_id === 0) {
$playlist = new Search((int) str_replace('smart_', '', (string)$playlist_id), 'song', $user);
if ($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names)) {
if (
$playlist->isNew() ||
($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names))
) {
continue;
}
$object_type = 'search';
Expand All @@ -1073,7 +1076,11 @@ public static function playlists($playlists, $user, $songs = false): string
$object_type = 'playlist';
$art_url = Art::url($playlist_id, $object_type, Core::get_request('auth'));
$playitem_total = $playlist->get_media_count('song');
if ($hide_dupe_searches && $playlist->user == $user->getId()) {
if (
$playlist->isNew() === false &&
$hide_dupe_searches &&
$playlist->user == $user->getId()
) {
$playlist_names[] = $playlist->name;
}
}
Expand Down

0 comments on commit 949d65a

Please sign in to comment.