diff --git a/apps/desktop/src/index.tsx b/apps/desktop/src/index.tsx index 038229e39..2aebce954 100644 --- a/apps/desktop/src/index.tsx +++ b/apps/desktop/src/index.tsx @@ -3,7 +3,7 @@ import { createRoot } from 'react-dom/client'; // import Spacedrive interface import SpacedriveInterface, { Platform } from '@sd/interface'; - +import { emit, listen, Event } from '@tauri-apps/api/event'; // import types from Spacedrive core (TODO: re-export from client would be cleaner) import { ClientCommand, ClientQuery, CoreEvent } from '@sd/core'; // import Spacedrive JS client @@ -16,6 +16,13 @@ import '@sd/ui/style'; // bind state to core via Tauri class Transport extends BaseTransport { + constructor() { + super(); + + listen('core_event', (e: Event) => { + this.emit('core_event', e.payload); + }); + } async query(query: ClientQuery) { return await invoke('client_query_transport', { data: query }); } @@ -47,9 +54,6 @@ function App() { return ( void; platform: Platform; convertFileSrc: (url: string) => string; openDialog: (options: { directory?: boolean }) => Promise; @@ -175,6 +174,8 @@ function AppContainer() { ); } +export function bindCoreEvent() {} + export default function App(props: AppProps) { // @ts-ignore: TODO: This is a hack and a better solution should probably be found. This exists so that the queryClient can be accessed within the subpackage '@sd/client'. Refer to for where this is used. if (window.ReactQueryClient === undefined) { diff --git a/packages/interface/src/components/file/Sidebar.tsx b/packages/interface/src/components/file/Sidebar.tsx index ae6c52437..209c74311 100644 --- a/packages/interface/src/components/file/Sidebar.tsx +++ b/packages/interface/src/components/file/Sidebar.tsx @@ -70,7 +70,7 @@ export const Sidebar: React.FC = (props) => { ]; return ( -
+
{appPropsContext?.platform === 'macOS' ? ( <>
@@ -79,7 +79,7 @@ export const Sidebar: React.FC = (props) => { = (props) => { return ( -
- -
- - - -
+
+ + + + - + {props.items.map((item, index) => (
{item.map((button, index) => ( diff --git a/packages/interface/src/hooks/useCoreEvents.tsx b/packages/interface/src/hooks/useCoreEvents.tsx index 34f983f0f..02e12055a 100644 --- a/packages/interface/src/hooks/useCoreEvents.tsx +++ b/packages/interface/src/hooks/useCoreEvents.tsx @@ -1,5 +1,6 @@ import { useContext, useEffect } from 'react'; import { CoreEvent } from '@sd/core'; +import { transport } from '@sd/client'; import { useQueryClient } from 'react-query'; import { useExplorerState } from '../components/file/FileList'; import { AppPropsContext } from '../App'; @@ -11,8 +12,7 @@ export function useCoreEvents() { const { addNewThumbnail } = useExplorerState(); useEffect(() => { // check Tauri Event type - // @ts-expect-error - appPropsContext?.onCoreEvent((e: CoreEvent) => { + transport?.on('core_event', (e: CoreEvent) => { switch (e?.key) { case 'NewThumbnail': addNewThumbnail(e.data.cas_id);