Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions renderer/components/kap-app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {AppProps} from 'next/app';
import classNames from 'classnames';

import useDarkMode from '../hooks/dark-mode';
import GlobalStyles from '../utils/global-styles';
import SentryErrorBoundary from '../utils/sentry-error-boundary';
import {WindowStateProvider} from '../hooks/window-state';

const KapApp = ({Component, pageProps}: AppProps) => {
const isDarkMode = useDarkMode();
const className = classNames('cover-window', {dark: isDarkMode});

return (
<div className={className}>
<SentryErrorBoundary>
<WindowStateProvider>
<Component {...pageProps}/>
<GlobalStyles/>
</WindowStateProvider>
</SentryErrorBoundary>
</div>
);
};

export default KapApp;
4 changes: 3 additions & 1 deletion renderer/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ module.exports = (nextConfig) => {
]
});

config.target = 'electron-renderer';
if (!options.isServer) {
config.target = 'electron-renderer';
}
config.devtool = 'cheap-module-source-map';

if (typeof nextConfig.webpack === 'function') {
Expand Down
39 changes: 4 additions & 35 deletions renderer/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
import {AppProps} from 'next/app';
import {useState, useEffect} from 'react';
import useDarkMode from '../hooks/dark-mode';
import GlobalStyles from '../utils/global-styles';
import SentryErrorBoundary from '../utils/sentry-error-boundary';
import {WindowStateProvider} from '../hooks/window-state';
import classNames from 'classnames';
import dynamic from 'next/dynamic';

const Kap = (props: AppProps) => {
const [isMounted, setIsMounted] = useState(false);

useEffect(() => {
setIsMounted(true);
}, []);

if (!isMounted) {
return null;
}

return <MainApp {...props}/>;
};

const MainApp = ({Component, pageProps}: AppProps) => {
const isDarkMode = useDarkMode();
const className = classNames('cover-window', {dark: isDarkMode});

return (
<div className={className}>
<SentryErrorBoundary>
<WindowStateProvider>
<Component {...pageProps}/>
<GlobalStyles/>
</WindowStateProvider>
</SentryErrorBoundary>
</div>
);
};
const Kap = dynamic<AppProps>(async () => import('../components/kap-app'), {
ssr: false
});

export default Kap;