mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-02 11:13:29 +00:00
parent
73f521a3b8
commit
b1ffbee9b1
|
@ -40,19 +40,22 @@ pub type ThumbnailKey = Vec<String>;
|
|||
pub enum ExplorerItem {
|
||||
Path {
|
||||
thumbnail: Option<ThumbnailKey>,
|
||||
has_created_thumbnail: bool, // this is important
|
||||
item: file_path_with_object::Data,
|
||||
},
|
||||
Object {
|
||||
thumbnail: Option<ThumbnailKey>,
|
||||
has_created_thumbnail: bool,
|
||||
item: object_with_file_paths::Data,
|
||||
},
|
||||
Location {
|
||||
item: location::Data,
|
||||
},
|
||||
NonIndexedPath {
|
||||
thumbnail: Option<ThumbnailKey>,
|
||||
has_created_thumbnail: bool,
|
||||
item: NonIndexedPathItem,
|
||||
},
|
||||
Location {
|
||||
item: location::Data,
|
||||
},
|
||||
SpacedropPeer {
|
||||
item: PeerMetadata,
|
||||
},
|
||||
|
|
|
@ -228,6 +228,8 @@ pub fn mount() -> AlphaRouter<Ctx> {
|
|||
} else {
|
||||
ExplorerItem::NonIndexedPath {
|
||||
thumbnail,
|
||||
// TODO: Actually check fs for existence of thumb
|
||||
has_created_thumbnail: false,
|
||||
item,
|
||||
}
|
||||
});
|
||||
|
@ -321,7 +323,7 @@ pub fn mount() -> AlphaRouter<Ctx> {
|
|||
let mut items = Vec::with_capacity(file_paths.len());
|
||||
|
||||
for file_path in file_paths {
|
||||
let thumbnail_exists_locally = if let Some(cas_id) = &file_path.cas_id {
|
||||
let has_created_thumbnail = if let Some(cas_id) = &file_path.cas_id {
|
||||
library
|
||||
.thumbnail_exists(&node, cas_id)
|
||||
.await
|
||||
|
@ -334,8 +336,9 @@ pub fn mount() -> AlphaRouter<Ctx> {
|
|||
thumbnail: file_path
|
||||
.cas_id
|
||||
.as_ref()
|
||||
.filter(|_| thumbnail_exists_locally)
|
||||
// .filter(|_| thumbnail_exists_locally)
|
||||
.map(|i| get_indexed_thumb_key(i, library.id)),
|
||||
has_created_thumbnail,
|
||||
item: file_path,
|
||||
})
|
||||
}
|
||||
|
@ -440,7 +443,7 @@ pub fn mount() -> AlphaRouter<Ctx> {
|
|||
.map(|fp| fp.cas_id.as_ref())
|
||||
.find_map(|c| c);
|
||||
|
||||
let thumbnail_exists_locally = if let Some(cas_id) = cas_id {
|
||||
let has_created_thumbnail = if let Some(cas_id) = cas_id {
|
||||
library.thumbnail_exists(&node, cas_id).await.map_err(|e| {
|
||||
rspc::Error::with_cause(
|
||||
ErrorCode::InternalServerError,
|
||||
|
@ -454,8 +457,8 @@ pub fn mount() -> AlphaRouter<Ctx> {
|
|||
|
||||
items.push(ExplorerItem::Object {
|
||||
thumbnail: cas_id
|
||||
.filter(|_| thumbnail_exists_locally)
|
||||
.map(|cas_id| get_indexed_thumb_key(cas_id, library.id)),
|
||||
has_created_thumbnail,
|
||||
item: object,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,12 +11,14 @@ export function useExplorerSearchParams() {
|
|||
|
||||
export function useExplorerItemData(explorerItem: ExplorerItem) {
|
||||
const newThumbnail = useSelector(explorerStore, (s) => {
|
||||
const firstThumbnail =
|
||||
const thumbnailKey =
|
||||
explorerItem.type === 'Label'
|
||||
? explorerItem.thumbnails?.[0]
|
||||
: 'thumbnail' in explorerItem && explorerItem.thumbnail;
|
||||
? // labels have .thumbnails, plural
|
||||
explorerItem.thumbnails?.[0]
|
||||
: // all other explorer items have .thumbnail singular
|
||||
'thumbnail' in explorerItem && explorerItem.thumbnail;
|
||||
|
||||
return !!(firstThumbnail && s.newThumbnails.has(flattenThumbnailKey(firstThumbnail)));
|
||||
return !!(thumbnailKey && s.newThumbnails.has(flattenThumbnailKey(thumbnailKey)));
|
||||
});
|
||||
|
||||
return useMemo(() => {
|
||||
|
|
|
@ -249,7 +249,7 @@ export type EphemeralRenameMany = { from_pattern: FromPattern; to_pattern: strin
|
|||
|
||||
export type EphemeralRenameOne = { from_path: string; to: string }
|
||||
|
||||
export type ExplorerItem = { type: "Path"; thumbnail: string[] | null; item: FilePathWithObject } | { type: "Object"; thumbnail: string[] | null; item: ObjectWithFilePaths } | { type: "Location"; item: Location } | { type: "NonIndexedPath"; thumbnail: string[] | null; item: NonIndexedPathItem } | { type: "SpacedropPeer"; item: PeerMetadata } | { type: "Label"; thumbnails: string[][]; item: LabelWithObjects }
|
||||
export type ExplorerItem = { type: "Path"; thumbnail: string[] | null; has_created_thumbnail: boolean; item: FilePathWithObject } | { type: "Object"; thumbnail: string[] | null; has_created_thumbnail: boolean; item: ObjectWithFilePaths } | { type: "NonIndexedPath"; thumbnail: string[] | null; has_created_thumbnail: boolean; item: NonIndexedPathItem } | { type: "Location"; item: Location } | { type: "SpacedropPeer"; item: PeerMetadata } | { type: "Label"; thumbnails: string[][]; item: LabelWithObjects }
|
||||
|
||||
export type ExplorerLayout = "grid" | "list" | "media"
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ export function getExplorerItemData(data?: ExplorerItem | null): ItemData {
|
|||
itemData.thumbnailKeys = [data.thumbnail];
|
||||
}
|
||||
|
||||
itemData.hasLocalThumbnail = !!data.thumbnail;
|
||||
itemData.hasLocalThumbnail = data.has_created_thumbnail;
|
||||
// handle file path
|
||||
const filePath = getItemFilePath(data);
|
||||
if (filePath) {
|
||||
|
@ -89,7 +89,7 @@ export function getExplorerItemData(data?: ExplorerItem | null): ItemData {
|
|||
itemData.thumbnailKeys = [data.thumbnail];
|
||||
}
|
||||
|
||||
itemData.hasLocalThumbnail = !!data.thumbnail;
|
||||
itemData.hasLocalThumbnail = data.has_created_thumbnail;
|
||||
// handle file path
|
||||
const filePath = getItemFilePath(data);
|
||||
if (filePath) {
|
||||
|
|
Loading…
Reference in a new issue