mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-24 08:22:10 -04:00
* Some initial drafts * Finising the first draft on non-indexed locations * Minor tweaks * Fix warnings * Adding date_created and date_modified to non indexed path entries * Add id and path properties to NonIndexedPathItem * Working ephemeral location (hardcoded home for now) * Fix UI for ephemeral locations * Fix windows * Passing ephemeral thumbnails to thumbnails remover * Indexing rules for ephemeral paths walking * Animate Location button when path text overflow it's size * Fix Linux not showing all volumes * Fix Linux - Add some missing no_os_protected rules for macOS - Improve ephemeral location names * Remove unecessary import * Fix Mobile * Improve resizing behaviour for ephemeral location topbar path button - Improve Search View (Replace custom empty component with Explorer's emptyNotice ) - Improve how TopBar children positioning * Hide EphemeralSection if there is no volume or home - Disable Ephemeral topbar path button animation when text is not overflowing * minor fixes * Introducing ordering for ephemeral paths * TS Format * Ephemeral locations UI fixes - Fix indexed Locations having no metadata - Remove date indexed/accessed options for sorting Ephemeral locations - Remove empty three dots from SideBar element when no settings is linked * Add tooltip to add location button in ephemeral locations * Fix indexed Locations selecting other folder/files in Ephemeral location * Minor fixes * Fix app breaking due to wrong logic to get item full path in Explorer * Revert some recent changes to Thumb.tsx * Fix original not loading for overview items - Fix QuickPreview name broken for overview items * Improve imports * Revert replace useEffect with useLayoutEffect for locked logic in ListView It was causing the component to full reload when clicking a header to sort per column * Changes from feedback * Hide some unused Inspector metadata fields on NonIndexedPaths - Merge formatDate functions while retaining original behaviour * Use tauri api for getting user home * Change ThumbType to a string enum to allow for string comparisons * Improve ObjectKind typing --------- Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { type ExplorerItem, getExplorerItemData } 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;
|
|
default:
|
|
return pubIdToString(item.item.pub_id);
|
|
}
|
|
};
|