Files
spacedrive/interface/hooks/useExplorerItemData.ts
Jamie Pine 8938ae6802 [ENG-708] Thumbnail sharding (#925)
* first phase, basic sharding

* improved API for sharding using a "thumbnailKey"

* clean up param handling for custom_uri

* added version manager with migrations for the thumbnail directory

* remove redundant hash of a hash, silly

* fix mobile

* fix clippy

---------

Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com>
2023-06-08 07:13:45 +00:00

24 lines
702 B
TypeScript

import { useMemo } from 'react';
import { ExplorerItem } from '@sd/client';
import { getExplorerItemData } from '~/app/$libraryId/Explorer/util';
import { flattenThumbnailKey, useExplorerStore } from './useExplorerStore';
export function useExplorerItemData(explorerItem: ExplorerItem) {
const explorerStore = useExplorerStore();
const newThumbnail = !!(
explorerItem.thumbnail_key &&
explorerStore.newThumbnails.has(flattenThumbnailKey(explorerItem.thumbnail_key))
);
return useMemo(() => {
const itemData = getExplorerItemData(explorerItem);
if (!itemData.hasLocalThumbnail) {
itemData.hasLocalThumbnail = newThumbnail;
}
return itemData;
}, [explorerItem, newThumbnail]);
}