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:
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user