Merge pull request #7894 from crobibero/search-hints

(cherry picked from commit 0f75f17736)
Signed-off-by: crobibero <cody@robibe.ro>
This commit is contained in:
Cody Robibero
2022-06-13 16:27:16 -06:00
committed by crobibero
parent b35d608b19
commit e4b095a766
2 changed files with 18 additions and 1 deletions

View File

@@ -57,5 +57,21 @@ namespace Jellyfin.Extensions
return -1;
}
/// <summary>
/// Get the first or default item from a list.
/// </summary>
/// <param name="source">The source list.</param>
/// <typeparam name="T">The type of item.</typeparam>
/// <returns>The first item or default if list is empty.</returns>
public static T? FirstOrDefault<T>(this IReadOnlyList<T>? source)
{
if (source is null || source.Count == 0)
{
return default;
}
return source[0];
}
}
}