feat: add media player controls and directory episodes

This commit is contained in:
ngfchl
2026-07-18 14:19:25 +08:00
parent f1ab8a9a3b
commit 6a5489fb4b
4 changed files with 578 additions and 18 deletions
@@ -16,6 +16,9 @@ class FileMetadataCache {
static Future<List<CloudFile>?> folderChildren(String? folderID) =>
_store.folderChildren(folderID);
static Future<List<CloudFile>?> siblingFiles(String fileID) =>
_store.siblingFiles(fileID);
static Future<CloudFile?> file(String fileID) => _store.cachedFile(fileID);
static Future<void> updateFolderChildren(
+25
View File
@@ -293,6 +293,31 @@ class MediaLibraryStore {
}
}
Future<List<CloudFile>?> siblingFiles(String fileID) async {
final rows = await (await _db).query(
'folder_children',
columns: const ['children_json'],
where: 'child_ids LIKE ?',
whereArgs: ['%"$fileID"%'],
);
for (final row in rows) {
try {
final raw = jsonDecode(row['children_json']?.toString() ?? '[]');
if (raw is! List) continue;
final files = raw
.whereType<Map>()
.map(
(value) => CloudFile.fromJson(Map<String, dynamic>.from(value)),
)
.toList();
if (files.any((file) => file.id == fileID)) return files;
} catch (_) {
// A stale cache row should not prevent looking at the next folder.
}
}
return null;
}
Future<CloudFile?> cachedFile(String fileID) async {
final rows = await (await _db).rawQuery(
'''SELECT d.file_json FROM file_index i