implemented Nextcloud file previews for unknown file types using fileId and has-preview flags, updated file models, and refined manual refresh logic.

This commit is contained in:
2026-05-13 19:44:26 +02:00
parent 843686358f
commit 092f9b622b
6 changed files with 174 additions and 41 deletions
+25 -5
View File
@@ -8,13 +8,33 @@ class RemoteFileRef {
final String path;
final String name;
const RemoteFileRef({required this.path, required this.name});
/// Nextcloud's instance-local file id, when known. Preferred over [path]
/// for hitting the preview API — the path-based variant is unreliable on
/// some server configurations.
final int? fileId;
/// Server's `nc:has-preview` flag when known. null = unknown.
final bool? hasPreview;
const RemoteFileRef({
required this.path,
required this.name,
this.fileId,
this.hasPreview,
});
/// Caller must verify `file.path != null` first — Talk message parameters
/// without a path (system events, mentions, polls) are not file refs.
factory RemoteFileRef.fromTalk(RichObjectString file) =>
RemoteFileRef(path: file.path!, name: file.name);
factory RemoteFileRef.fromTalk(RichObjectString file) => RemoteFileRef(
path: file.path!,
name: file.name,
fileId: int.tryParse(file.id),
);
factory RemoteFileRef.fromCacheable(CacheableFile file) =>
RemoteFileRef(path: file.path, name: file.name);
factory RemoteFileRef.fromCacheable(CacheableFile file) => RemoteFileRef(
path: file.path,
name: file.name,
fileId: file.fileId,
hasPreview: file.hasPreview,
);
}