mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-02-20 15:43:58 -05:00
* Update rspc, prisma-client-rust, axum and tanstack-query - Deleted some unused examples and fully commented out frontend code - Implement many changes required due to the updates - Update most rust dependencies * Re-enable p2p * Fix server * Auto format * Fix injected script format - Update some github actions - Update pnpm lock file * Fix devtools showing up when app opens - Fix million complaining about Sparkles component * Fix sd-server * Fix and improve thumbnails rendering - Fix core always saying a new thumbnail was generated even for files that it skiped thumbnail generation - Rewrite FileThumb and improve related components * Ignore tmp files when running prettier * Improve FileThumb component performance - Rework useExplorerDraggable and useExplorerItemData hooks due to reduce unecessary re-renders * More fixes for thumb component - A couple of minor performance improvements to frontend code * auto format * Fix Thumbnail and QuickPreview * Fix logic for when to show 'fail to load original' error message in QuickPreview - Updated prisma-client-rust, libp2p, tauri, tauri-specta, rspc and hyper * Fix type checking - Format scripts * Add script prettier config * Fix serde missing feature - Use rust-libp2p spacedrive fork again - Update rspc * Autoformat + fix pnpm lock * Fix thumbnail first load again * Autoformat * autoformat * Fix rust-libp2p fork url again? * Remove usePathsInfiniteQuery hook * Update tauri 2.0.6
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
|
|
import { OperatingSystem, usePlatform } from '../util/Platform';
|
|
|
|
export function guessOperatingSystem(): OperatingSystem {
|
|
let os: OperatingSystem = 'unknown';
|
|
if (navigator.userAgent.indexOf('Win') != -1) os = 'windows';
|
|
if (navigator.userAgent.indexOf('Mac') != -1) os = 'macOS';
|
|
if (navigator.userAgent.indexOf('X11') != -1 || navigator.userAgent.indexOf('Linux') != -1)
|
|
os = 'linux';
|
|
return os;
|
|
}
|
|
|
|
// This hook will return the current os we are using.
|
|
// It will guess the OS on first render until Tauri responds with a more accurate answer.
|
|
// This means the app can open insanely quickly without any weird layout shift.
|
|
// Setting `realOs` to true will return a best guess of the underlying operating system instead of 'browser'.
|
|
export function useOperatingSystem(realOs?: boolean): OperatingSystem {
|
|
const platform = usePlatform();
|
|
const { data } = useQuery({
|
|
queryKey: ['_tauri', 'platform'],
|
|
queryFn: async () => {
|
|
return platform.getOs ? await platform.getOs() : guessOperatingSystem();
|
|
},
|
|
// Here we guess the users operating system from the user agent for the first render.
|
|
initialData: guessOperatingSystem,
|
|
enabled: platform.getOs !== undefined
|
|
});
|
|
|
|
return platform.platform === 'web' && !realOs ? 'browser' : data;
|
|
}
|