Add progress/recently-added sort to Library browser
The sort dropdown only had Name (A-Z/Z-A) - no way to surface "what did I just download" or "what am I closest to finishing" without scrolling. Adds Progress and Recently Added, backed by each course's completion_percentage and folder mtime (already/newly attached in list_library_directory and search_library_courses). Folders have neither, so they naturally sort to the end under these two modes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1288,6 +1288,10 @@ def list_library_directory(dir_path: str, skip_hidden: bool = True) -> Dict[str,
|
||||
item['hidden'] = is_hidden
|
||||
item['favorited'] = os.path.abspath(entry_path_str) in favorite_set
|
||||
item['completion_percentage'] = _course_completion_percentage(entry, item['media_files'])
|
||||
try:
|
||||
item['mtime'] = entry.stat().st_mtime
|
||||
except OSError:
|
||||
item['mtime'] = 0
|
||||
items.append(item)
|
||||
else:
|
||||
if skip_hidden:
|
||||
@@ -2078,6 +2082,10 @@ def search_library_courses(query: str) -> List[Dict[str, Any]]:
|
||||
item = _course_summary(course)
|
||||
item['favorited'] = os.path.abspath(str(course)) in favorite_set
|
||||
item['completion_percentage'] = _course_completion_percentage(course, item['media_files'])
|
||||
try:
|
||||
item['mtime'] = course.stat().st_mtime
|
||||
except OSError:
|
||||
item['mtime'] = 0
|
||||
results.append(item)
|
||||
return results
|
||||
|
||||
|
||||
Reference in New Issue
Block a user