mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-22 23:48:26 -04:00
* added buttons for zoom in and out * currently added only English translation * added magnification prop * added a `div` Wrapper for Scrolling * Update Original.tsx * Update de/common.json * Update es/common.json * Update fr/common.json * Update it/common.json * Update js/common.json * Update nl/common.json * Update ru/common.json * Update tr/common.json * Update by/common.json * Update zh-CN/common.json * Update zh-TW/common.json * Reset Zoom * Squashed commit of the following: commit 36ae94c998874b5aaf79be0b87d1c05c605b1ff0 Merge: df0201729ff0f58a92Author: Aditya <raghavbhai4545@gmail.com> Date: Sat Apr 27 21:35:22 2024 +0530 Merge branch 'spacedriveapp:main' into main commitff0f58a921Author: ameer2468 <33054370+ameer2468@users.noreply.github.com> Date: Sat Apr 27 18:08:07 2024 +0300 [MOB-89] Separate headers (#2408) * separate headers improvements to headers cleanup missed cleanup documentation * Update SearchStack.tsx commit9e0b1a8840Author: ameer2468 <33054370+ameer2468@users.noreply.github.com> Date: Fri Apr 26 20:36:21 2024 +0300 Windows mouse resize fix (#2407) Update useMouseItemResize.ts commita6abb4062aAuthor: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Date: Thu Apr 25 21:29:55 2024 -0300 Revert OpenDAL for ephemeral location (#2399) * Revert "OpenDAL - Ephemeral Locations (#2283)" This reverts commitf982d65417. * Format * Fix some diff problems commit47b0c40752Author: Arnab Chakraborty <11457760+Rocky43007@users.noreply.github.com> Date: Thu Apr 25 20:29:55 2024 -0400 Alpha 0.2.13 (#2394) bump commitecd5b3a8fbAuthor: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Date: Thu Apr 25 21:20:36 2024 -0300 Fix server release again (#2403) * Fix server release again * small improvement to regex commitb0bf1f0ffcAuthor: Jamie Pine <32987599+jamiepine@users.noreply.github.com> Date: Thu Apr 25 14:37:25 2024 -0700 Reactive file identification (#2396) * yes * Explain mysterious if * Use id alias just for consistency reasons * yes * Rust fmt * fix ts --------- Co-authored-by: Ericson "Fogo" Soares <ericson.ds999@gmail.com> Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com> commit5309a4718bAuthor: Utku <74243531+utkubakir@users.noreply.github.com> Date: Thu Apr 25 16:06:35 2024 -0400 Fix title (#2398) * fix task manager title * 2 more config item commit84c50ddd86Author: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Date: Thu Apr 25 14:58:50 2024 -0300 Fix `cargo test` & improve `pnpm prep` native deps download (#2393) Couple of fixes - Increase `pnpm prep` connection timeout to 5min, to better handle downloading native deps under flaky network conditions - Fix `cargo test` and cache-factory CI - Clippy and fmt commit0068788169Author: ameer2468 <33054370+ameer2468@users.noreply.github.com> Date: Thu Apr 25 20:29:46 2024 +0300 [ENG-1762] Reverse mouse resize direction (#2395) Update useMouseItemResize.ts commit304e763b71Author: Artsiom Voitas <artsiom.voitas@gmail.com> Date: Thu Apr 25 19:26:36 2024 +0300 Improved translation into Belarusian and Russian (#2391) * feat: improved translation on belarusian and russian * updated keys related to vacuum * updated keys related to vacuum commitca9043704cAuthor: Jamie Pine <32987599+jamiepine@users.noreply.github.com> Date: Thu Apr 25 09:14:43 2024 -0700 Fix thumbnail generation reactivity (#2392) fix commitf40f93d34cAuthor: Ericson "Fogo" Soares <ericson.ds999@gmail.com> Date: Thu Apr 25 01:06:11 2024 -0300 [ENG-1629] Write new file identifier with the task system (#2334) * Introduce deep vs shallow for indexer tasks with different priorities * Make job wait to dispatch if it's paused * Extract file metadata task on file identifier job * Some initial drafts on object processor task * Object processor task for file identifier * File Identifier job and shallow commit8c19c52e80Author: Heavysnowjakarta <54460050+HeavySnowJakarta@users.noreply.github.com> Date: Thu Apr 25 07:38:34 2024 +0800 I18n polish (zh-cn) (#2337) * i18n some polishes * reviewed 1st-100th strings of zh-cn i18n * change the indent to 2 space characters commitd7827f50a7Author: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Date: Wed Apr 24 20:37:38 2024 -0300 Fix core test (#2386) * Fix core test * Import CompressedCRDTOperations --------- Co-authored-by: Ericson "Fogo" Soares <ericson.ds999@gmail.com> commit3aa3476270Author: ameer2468 <33054370+ameer2468@users.noreply.github.com> Date: Thu Apr 25 02:34:24 2024 +0300 [MOB-90] Visual adjustments (#2383) * Visual adjustments * Update Tags.tsx * cleanup * remove prop * remove hitslop * sectionlist commitfc91a10c07Author: Arnab Chakraborty <11457760+Rocky43007@users.noreply.github.com> Date: Wed Apr 24 14:20:51 2024 -0400 Small Trash UI fixes (#2385) * Update index.tsx * More ui fixes + toast * Update index.tsx * Add Translations commit5ce273efadAuthor: Utku <74243531+utkubakir@users.noreply.github.com> Date: Wed Apr 24 12:48:14 2024 -0400 hide placeholders (#2384) commit1762cb05d1Author: Utku <74243531+utkubakir@users.noreply.github.com> Date: Wed Apr 24 10:25:22 2024 -0400 Alpha 0.2.12 (#2382) * pnpm * alpha 0.2.12 * make pnpm version non strict commit496858ad95Author: Oscar Beaumont <oscar@otbeaumont.me> Date: Wed Apr 24 18:09:18 2024 +0800 Fix main (#2381) * fix * fix commit14746970b9Author: Oscar Beaumont <oscar@otbeaumont.me> Date: Wed Apr 24 16:43:30 2024 +0800 Improved p2p settings (#2379) improved p2p settings commitdee23147d8Author: Brendan Allan <brendonovich@outlook.com> Date: Wed Apr 24 16:26:50 2024 +0800 Batch ingest sync operations (#2378) batch ingest sync operations commita69953e261Author: Oscar Beaumont <oscar@otbeaumont.me> Date: Wed Apr 24 16:27:31 2024 +0800 Block size (#2377) Block size + some Clippy commitdc5a0bb107Author: Utku <74243531+utkubakir@users.noreply.github.com> Date: Tue Apr 23 19:20:59 2024 -0400 Revert "[MOB-85] Better headers" (#2376) Revert "[MOB-85] Better headers (#2375)" This reverts commitfdd8ce3d2b. commitfdd8ce3d2bAuthor: ameer2468 <33054370+ameer2468@users.noreply.github.com> Date: Wed Apr 24 01:21:31 2024 +0300 [MOB-85] Better headers (#2375) * wip * improve headers * cleanup commit4eea236845Author: Arnab Chakraborty <11457760+Rocky43007@users.noreply.github.com> Date: Mon Apr 22 15:46:10 2024 -0400 Open Trash from the application (#2338) * Open Trash from the application * Working Trash Sidebar Button * Small UI fixes * Update common.json * Move openTrash to Tauri Command instead of RSPC * format and remove type assertion --------- Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com> commitbbbc6322e0Author: nikec <43032218+niikeec@users.noreply.github.com> Date: Mon Apr 22 20:54:42 2024 +0200 [ENG-1751] Improve active item handling (#2367) base commit6e3bc06748Author: Oscar Beaumont <oscar@otbeaumont.me> Date: Mon Apr 22 20:43:44 2024 +0800 Reintroduce P2P Settings (#2365) * redo backend to be less cringe * fixed up commit1a73349ab5Author: Oscar Beaumont <oscar@otbeaumont.me> Date: Mon Apr 22 19:47:47 2024 +0800 Remove indexer rules from ephemeral indexer (#2319) remove indexer rules from ephemeral indexer commit1ae584e196Author: Brendan Allan <brendonovich@outlook.com> Date: Mon Apr 22 18:29:54 2024 +0800 Ignore empty object/filepath search filters (#2371) commit63a43d0501Author: Oscar Beaumont <oscar@otbeaumont.me> Date: Mon Apr 22 18:28:35 2024 +0800 Show errors creating P2P listeners on startup (#2372) * do it * fix accuracy * `useRef` as god intended commit72caf12960Author: nikec <43032218+niikeec@users.noreply.github.com> Date: Mon Apr 22 12:27:30 2024 +0200 [ENG-1753] Only open quick preview when items are selected (#2374) only toggle when items are selected commitc3d7bdb42eAuthor: nikec <43032218+niikeec@users.noreply.github.com> Date: Mon Apr 22 12:25:53 2024 +0200 [ENG-1752] Fix explorer selection reset when closing quick preview via keybind (#2373) prevent selection reset commit16b5753b74Author: Oscar Beaumont <oscar@otbeaumont.me> Date: Mon Apr 22 18:12:06 2024 +0800 Fix Docker start command (#2370) commit369d9fd848Author: ameer2468 <33054370+ameer2468@users.noreply.github.com> Date: Sun Apr 21 17:28:27 2024 +0300 [ENG-1750] Update context menu colors (#2369) update context menu colors commit df0201729278dfa11126b41922e404146c151a35 Merge:472e29a99619a4c8b6 Author: Aditya <raghavbhai4545@gmail.com> Date: Sat Apr 20 13:14:52 2024 +0530 Merge branch 'main' of https://github.com/Raghav-45/spacedrive commit5ca4277176Author: Oscar Beaumont <oscar@otbeaumont.me> Date: Sat Apr 20 11:21:20 2024 +0800 Remove files over p2p feature (#2364) * goodbye * types * a commit1cb2b24580Author: ameer2468 <33054370+ameer2468@users.noreply.github.com> Date: Sat Apr 20 02:18:54 2024 +0300 [ENG-1745] Mouse wheel resize (#2366) * Resize layout items with mouse wheel icon/item size using mouse wheel Update useMouseItemResize.ts Update useMouseItemResize.ts * improve comment * fb * Update useMouseItemResize.ts * Update IconSize.tsx commit 619a4c8b6dfe7239bce1b54b528a3176aa7350da Merge: df4f6279b5faaa9f84Author: Aditya <raghavbhai4545@gmail.com> Date: Tue Aug 29 16:59:18 2023 +0530 Merge branch 'spacedriveapp:main' into main commit df4f6279bfbd7bdaa120212b19db72cfae0d17c7 Merge: dfb5192067781f5be4Author: Aditya <raghavbhai4545@gmail.com> Date: Tue Aug 22 20:44:09 2023 +0530 Merge branch 'spacedriveapp:main' into main commit dfb51920667c24ff05b16ebc63bf4aea33225002 Merge: c1bfc329666014885fAuthor: Aditya <raghavbhai4545@gmail.com> Date: Thu Aug 17 21:22:49 2023 +0530 Merge branch 'spacedriveapp:main' into main commit c1bfc3296ee7686a6a142d74a91cf13cf4bd7677 Merge: de274c331717e01ef1Author: Aditya <raghavbhai4545@gmail.com> Date: Tue Aug 15 19:43:43 2023 +0530 Merge branch 'spacedriveapp:main' into main commit de274c3317cff942e9c3a4f2c8c08819a897d251 Merge: 14faf0bce0cbadf025Author: Aditya <raghavbhai4545@gmail.com> Date: Sun Aug 13 21:54:16 2023 +0530 Merge branch 'spacedriveapp:main' into main commit 14faf0bce2ee9123bf66706812357d6aefc44dea Merge: 3e013d8bd05db7f121Author: Aditya <raghavbhai4545@gmail.com> Date: Thu Aug 10 06:54:01 2023 -0400 Merge branch 'spacedriveapp:main' into main commit 3e013d8bdef2ba59536c90044be4312336b6cd8a Merge:2e702f2ebb3181ac92Author: Aditya <raghavbhai4545@gmail.com> Date: Tue Aug 8 11:21:07 2023 -0400 Merge branch 'spacedriveapp:main' into main commit2e702f2ebaAuthor: Brendan Allan <brendonovich@outlook.com> Date: Tue Aug 8 07:58:58 2023 -0700 Mention pnpm dev:web in CONTRIBUTING.md commita1c5c55a37Author: Raghav-45 <77260113+Raghav-45@users.noreply.github.com> Date: Tue Aug 8 18:49:50 2023 +0530 Update command to run server I encountered an issue where the cargo run -p server command was not functioning properly. It took me nearly an hour to pinpoint the problem, which turned out to be related to a modification in the Cargo.toml file. This change was made by @Brendonovich during their work on issue #1181, which pertained to *syncing ingestion*. Initially, I believed that re-cloning the repository from GitHub would resolve the issue. However, after attempting this solution exactly 5 times, I realized my assumption was incorrect. Despite the time and effort spent, I was able to successfully identify and rectify the problem. * conflicts * Revert "conflicts" This reverts commit2f1066a0a3. * Revert "Squashed commit of the following:" This reverts commitcd2435edaf. * change in line endings from 'LF' to 'CRLF'. * Update common.json * Update common.json * Update common.json * fixed indent --------- Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com>
247 lines
6.6 KiB
TypeScript
247 lines
6.6 KiB
TypeScript
import { getIcon, iconNames } from '@sd/assets/util';
|
|
import clsx from 'clsx';
|
|
import {
|
|
SyntheticEvent,
|
|
useEffect,
|
|
useMemo,
|
|
useRef,
|
|
useState,
|
|
type VideoHTMLAttributes
|
|
} from 'react';
|
|
import { getItemFilePath, useLibraryContext } from '@sd/client';
|
|
import i18n from '~/app/I18n';
|
|
import { PDFViewer, TextViewer } from '~/components';
|
|
import { useLocale } from '~/hooks';
|
|
import { pdfViewerEnabled } from '~/util/pdfViewer';
|
|
import { usePlatform } from '~/util/Platform';
|
|
|
|
import { useExplorerContext } from '../Context';
|
|
import { explorerStore } from '../store';
|
|
import { ExplorerItemData } from '../useExplorerItemData';
|
|
import { Image } from './Image';
|
|
import { useBlackBars, useSize } from './utils';
|
|
|
|
interface OriginalRendererProps {
|
|
src: string;
|
|
className: string;
|
|
frameClassName: string;
|
|
itemData: ExplorerItemData;
|
|
isDark: boolean;
|
|
childClassName?: string;
|
|
size?: number;
|
|
magnification?: number;
|
|
mediaControls?: boolean;
|
|
frame?: boolean;
|
|
isSidebarPreview?: boolean;
|
|
pauseVideo?: boolean;
|
|
blackBars?: boolean;
|
|
blackBarsSize?: number;
|
|
onLoad?(): void;
|
|
onError?(e: ErrorEvent | SyntheticEvent<Element, Event>): void;
|
|
}
|
|
|
|
export function Original({
|
|
itemData,
|
|
filePath,
|
|
...props
|
|
}: Omit<OriginalRendererProps, 'src'> & {
|
|
filePath: ReturnType<typeof getItemFilePath>;
|
|
}) {
|
|
const [error, setError] = useState(false);
|
|
if (error) throw new Error('onError');
|
|
|
|
const Renderer = useMemo(() => {
|
|
const kind = originalRendererKind(itemData);
|
|
return ORIGINAL_RENDERERS[kind];
|
|
}, [itemData]);
|
|
|
|
if (!Renderer) throw new Error('no renderer!');
|
|
|
|
const platform = usePlatform();
|
|
const { library } = useLibraryContext();
|
|
const { parent } = useExplorerContext();
|
|
|
|
const src = useMemo(() => {
|
|
const locationId =
|
|
itemData.locationId ?? (parent?.type === 'Location' ? parent.location.id : null);
|
|
|
|
if (filePath && (itemData.extension !== 'pdf' || pdfViewerEnabled())) {
|
|
if ('id' in filePath && locationId)
|
|
return platform.getFileUrl(library.uuid, locationId, filePath.id);
|
|
else if ('path' in filePath) return platform.getFileUrlByPath(filePath.path);
|
|
}
|
|
}, [itemData, filePath, library.uuid, parent, platform]);
|
|
|
|
if (src === undefined) throw new Error('no src!');
|
|
|
|
return <Renderer src={src} itemData={itemData} onError={() => setError(true)} {...props} />;
|
|
}
|
|
|
|
const TEXT_RENDERER: OriginalRenderer = (props) => (
|
|
<TextViewer
|
|
src={props.src}
|
|
onLoad={props.onLoad}
|
|
onError={props.onError}
|
|
className={clsx(
|
|
'textviewer-scroll size-full overflow-y-auto whitespace-pre-wrap break-words px-4 font-mono',
|
|
!props.mediaControls ? 'overflow-hidden' : 'overflow-auto',
|
|
props.className,
|
|
props.frame && [props.frameClassName, '!bg-none p-2']
|
|
)}
|
|
codeExtension={
|
|
((props.itemData.kind === 'Code' || props.itemData.kind === 'Config') &&
|
|
props.itemData.extension) ||
|
|
''
|
|
}
|
|
isSidebarPreview={props.isSidebarPreview}
|
|
/>
|
|
);
|
|
|
|
type OriginalRenderer = (props: OriginalRendererProps) => JSX.Element;
|
|
|
|
function originalRendererKind(itemData: ExplorerItemData) {
|
|
return itemData.extension === 'pdf' ? 'PDF' : itemData.kind;
|
|
}
|
|
|
|
type OriginalRendererKind = ReturnType<typeof originalRendererKind>;
|
|
|
|
const ORIGINAL_RENDERERS: {
|
|
[K in OriginalRendererKind]?: OriginalRenderer;
|
|
} = {
|
|
PDF: (props) => (
|
|
<PDFViewer
|
|
src={props.src}
|
|
onLoad={props.onLoad}
|
|
onError={props.onError}
|
|
className={clsx('size-full', props.className, props.frame && props.frameClassName)}
|
|
crossOrigin="anonymous" // Here it is ok, because it is not a react attr
|
|
/>
|
|
),
|
|
Text: TEXT_RENDERER,
|
|
Code: TEXT_RENDERER,
|
|
Config: TEXT_RENDERER,
|
|
Video: (props) => (
|
|
<Video
|
|
src={props.src}
|
|
onLoadedData={props.onLoad}
|
|
onError={props.onError}
|
|
paused={props.pauseVideo}
|
|
controls={props.mediaControls}
|
|
blackBars={props.blackBars}
|
|
blackBarsSize={props.blackBarsSize}
|
|
className={clsx(
|
|
props.className,
|
|
props.frame && !props.blackBars && props.frameClassName
|
|
)}
|
|
/>
|
|
),
|
|
Audio: (props) => (
|
|
<>
|
|
<img
|
|
src={getIcon(iconNames.Audio, props.isDark, props.itemData.extension)}
|
|
onLoad={props.onLoad}
|
|
decoding={props.size ? 'async' : 'sync'}
|
|
className={props.childClassName}
|
|
draggable={false}
|
|
/>
|
|
{props.mediaControls && (
|
|
<audio
|
|
// Order matter for crossOrigin attr
|
|
crossOrigin="anonymous"
|
|
src={props.src}
|
|
onError={props.onError}
|
|
controls
|
|
autoPlay
|
|
className="absolute left-2/4 top-full w-full -translate-x-1/2 translate-y-[-150%]"
|
|
>
|
|
<p>{i18n.t('audio_preview_not_supported')}</p>
|
|
</audio>
|
|
)}
|
|
</>
|
|
),
|
|
Image: (props) => {
|
|
const ref = useRef<HTMLImageElement>(null);
|
|
const size = useSize(ref);
|
|
|
|
return (
|
|
<div className="custom-scroll quick-preview-images-scroll flex size-full justify-center transition-all">
|
|
<Image
|
|
ref={ref}
|
|
src={props.src}
|
|
size={size}
|
|
style={{ transform: `scale(${props.magnification})` }}
|
|
onLoad={props.onLoad}
|
|
onError={props.onError}
|
|
decoding={props.size ? 'async' : 'sync'}
|
|
className={clsx(
|
|
props.className,
|
|
props.frameClassName,
|
|
'origin-center transition-transform'
|
|
)}
|
|
crossOrigin="anonymous" // Here it is ok, because it is not a react attr
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
};
|
|
|
|
interface VideoProps extends VideoHTMLAttributes<HTMLVideoElement> {
|
|
paused?: boolean;
|
|
blackBars?: boolean;
|
|
blackBarsSize?: number;
|
|
}
|
|
|
|
const Video = ({ paused, blackBars, blackBarsSize, className, ...props }: VideoProps) => {
|
|
const { t } = useLocale();
|
|
|
|
const ref = useRef<HTMLVideoElement>(null);
|
|
|
|
const size = useSize(ref);
|
|
|
|
const { style: blackBarsStyle } = useBlackBars(ref, size, {
|
|
size: blackBarsSize,
|
|
disabled: !blackBars
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (!ref.current) return;
|
|
paused ? ref.current.pause() : ref.current.play();
|
|
}, [paused]);
|
|
|
|
return (
|
|
<video
|
|
// Order matter for crossOrigin attr
|
|
crossOrigin="anonymous"
|
|
ref={ref}
|
|
autoPlay={!paused}
|
|
onVolumeChange={(e) => {
|
|
const video = e.target as HTMLVideoElement;
|
|
explorerStore.mediaPlayerVolume = video.volume;
|
|
}}
|
|
onCanPlay={(e) => {
|
|
const video = e.target as HTMLVideoElement;
|
|
// Why not use the element's attribute? Because React...
|
|
// https://github.com/facebook/react/issues/10389
|
|
video.loop = !props.controls;
|
|
video.muted = !props.controls;
|
|
video.volume = explorerStore.mediaPlayerVolume;
|
|
}}
|
|
playsInline
|
|
draggable={false}
|
|
style={{ ...blackBarsStyle }}
|
|
className={clsx(blackBars && size.width === 0 && 'invisible', className)}
|
|
{...props}
|
|
key={props.src}
|
|
controls={false}
|
|
onTimeUpdate={(e) => {
|
|
const video = e.target as HTMLVideoElement;
|
|
if (video.currentTime > 0) {
|
|
video.controls = props.controls ?? true;
|
|
}
|
|
}}
|
|
>
|
|
<p>{t('video_preview_not_supported')}</p>
|
|
</video>
|
|
);
|
|
};
|