mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-22 07:28:43 -04:00
* - added local section to sidebar - added spacedrop screen, showing local peers - added placeholder network screen -removed unused swift package - created a watcher for system volumes to invalidate ui when drives are added/removed * clouds * fix more imports * see more * open location if volume is location * gen assets * remove log * [ENG-939, ENG-1173] PDF Thumbnails (#1242) * sd-pdf * Process PDF blocking render inside a spawn_blocking - Load a single global Pdfium instance * Migrate pdf thumb logic to sd-images - Replace block_in_place with spawn_blocking - Only load LibHeif once - Allow thumbnailer (both indexed and non-indexed locations) to process documents - Disable loading pdf viewer in Inspection in favour of loading it's thumbnail * Try to load pdfium lib from absolute path * Revert removed import due to rebase * Small nitpick and some warnings --------- Co-authored-by: Ericson Fogo Soares <ericson.ds999@gmail.com> * [ENG-888] Media view should show current folder downward (#1437) * Done but ugly * layout * Now with a select --------- Co-authored-by: ameer2468 <33054370+ameer2468@users.noreply.github.com> * add cool folder thing to inspector + stuff * fix text color * fix lock * fix typescript * fix ts --------- Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com> Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Co-authored-by: Ericson Fogo Soares <ericson.ds999@gmail.com> Co-authored-by: ameer2468 <33054370+ameer2468@users.noreply.github.com> Co-authored-by: Brendan Allan <brendonovich@outlook.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { getExplorerItemData, type ExplorerItem } from '@sd/client';
|
|
import { ExplorerParamsSchema } from '~/app/route-schemas';
|
|
import { useZodSearchParams } from '~/hooks';
|
|
|
|
import { flattenThumbnailKey, useExplorerStore } from './store';
|
|
|
|
export function useExplorerSearchParams() {
|
|
return useZodSearchParams(ExplorerParamsSchema);
|
|
}
|
|
|
|
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]);
|
|
}
|
|
|
|
export const pubIdToString = (pub_id: number[]) =>
|
|
pub_id.map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
|
|
export const uniqueId = (item: ExplorerItem | { pub_id: number[] }) => {
|
|
if ('pub_id' in item) return pubIdToString(item.pub_id);
|
|
|
|
const { type } = item;
|
|
|
|
switch (type) {
|
|
case 'NonIndexedPath':
|
|
return item.item.path;
|
|
case 'SpacedropPeer':
|
|
return item.item.name;
|
|
default:
|
|
return pubIdToString(item.item.pub_id);
|
|
}
|
|
};
|