Add conditional for preload functions
This commit is contained in:
parent
4614358163
commit
1fbdfe725c
9 changed files with 13 additions and 10 deletions
|
@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
|||
import isElectron from 'is-electron';
|
||||
import { FileInput, Text, Button } from '/@/renderer/components';
|
||||
|
||||
const localSettings = window.electron.localSettings;
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
|
||||
export const MpvRequired = () => {
|
||||
const [mpvPath, setMpvPath] = useState('');
|
||||
|
|
|
@ -12,7 +12,7 @@ import { AnimatedPage } from '/@/renderer/features/shared';
|
|||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
|
||||
const localSettings = window.electron.localSettings;
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
|
||||
const ActionRequiredRoute = () => {
|
||||
const currentServer = useCurrentServer();
|
||||
|
|
|
@ -2,6 +2,7 @@ import type { MutableRefObject } from 'react';
|
|||
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
||||
import { Group } from '@mantine/core';
|
||||
import { Button, Popover, TableConfigDropdown } from '/@/renderer/components';
|
||||
import isElectron from 'is-electron';
|
||||
import {
|
||||
RiArrowDownLine,
|
||||
RiArrowUpLine,
|
||||
|
@ -14,7 +15,7 @@ import { Song } from '/@/renderer/api/types';
|
|||
import { useQueueControls } from '/@/renderer/store';
|
||||
import { TableType } from '/@/renderer/types';
|
||||
|
||||
const mpvPlayer = window.electron.mpvPlayer;
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
|
||||
interface PlayQueueListOptionsProps {
|
||||
tableRef: MutableRefObject<{ grid: AgGridReactType<Song> } | null>;
|
||||
|
|
|
@ -27,13 +27,14 @@ import {
|
|||
useTableSettings,
|
||||
} from '/@/renderer/store/settings.store';
|
||||
import { useMergedRef } from '@mantine/hooks';
|
||||
import isElectron from 'is-electron';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import { VirtualTable } from '/@/renderer/components/virtual-table';
|
||||
import { ErrorFallback } from '/@/renderer/features/action-required';
|
||||
import { TableType } from '/@/renderer/types';
|
||||
import { QueueSong } from '/@/renderer/api/types';
|
||||
|
||||
const mpvPlayer = window.electron.mpvPlayer;
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
|
||||
type QueueProps = {
|
||||
type: TableType;
|
||||
|
|
|
@ -9,8 +9,9 @@ import { useAuthStore, usePlayerStore } from '/@/renderer/store';
|
|||
import { useSettingsStore } from '/@/renderer/store/settings.store';
|
||||
import { PlayQueueAddOptions, LibraryItem, Play, PlaybackType } from '/@/renderer/types';
|
||||
import { toast } from '/@/renderer/components/toast';
|
||||
import isElectron from 'is-electron';
|
||||
|
||||
const mpvPlayer = window.electron.mpvPlayer;
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
|
||||
export const useHandlePlayQueueAdd = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
|
|
@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
|||
import isElectron from 'is-electron';
|
||||
import { useMuted, usePlayerControls, useVolume } from '/@/renderer/store';
|
||||
|
||||
const mpvPlayer = window.electron.mpvPlayer;
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
|
||||
export const useRightControls = () => {
|
||||
const { setVolume, setMuted } = usePlayerControls();
|
||||
|
|
|
@ -18,8 +18,8 @@ import { useCurrentStatus, usePlayerStore } from '/@/renderer/store';
|
|||
import { useSettingsStore, useSettingsStoreActions } from '/@/renderer/store/settings.store';
|
||||
import { PlaybackType, PlayerStatus, PlaybackStyle, CrossfadeStyle, Play } from '/@/renderer/types';
|
||||
|
||||
const localSettings = window.electron.localSettings;
|
||||
const mpvPlayer = window.electron.mpvPlayer;
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
|
||||
const getAudioDevice = async () => {
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
|
|
|
@ -3,7 +3,7 @@ import isElectron from 'is-electron';
|
|||
import { RiCheckboxBlankLine, RiCloseLine, RiSubtractLine } from 'react-icons/ri';
|
||||
import styled from 'styled-components';
|
||||
|
||||
const browser = window.electron.browser;
|
||||
const browser = isElectron() ? window.electron.browser : null;
|
||||
|
||||
interface WindowControlsProps {
|
||||
style?: 'macos' | 'windows' | 'linux';
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Navigate, Outlet, useLocation } from 'react-router-dom';
|
|||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
|
||||
const localSettings = window.electron.localSettings;
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
|
||||
export const AppOutlet = () => {
|
||||
const location = useLocation();
|
||||
|
|
Reference in a new issue