-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eaa773
commit 9341a56
Showing
27 changed files
with
356 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { JSX } from 'react'; | ||
import { RouterProvider } from 'react-router-dom'; | ||
import { router } from './router.tsx'; | ||
import { FloatingConfig } from './components/floating-config.tsx'; | ||
import { Notification } from './components/notification.tsx'; | ||
|
||
/** | ||
* The main application component. | ||
*/ | ||
export function App(): JSX.Element { | ||
return ( | ||
<div className="mx-auto max-w-screen-lg"> | ||
<FloatingConfig /> | ||
<RouterProvider router={router} /> | ||
<Notification /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { urlConfigSelector, useAppSelector, useFetchConfigUrl } from '../store'; | ||
import { Loading } from 'react-daisyui'; | ||
import QRCode from 'react-qr-code'; | ||
import { useEffect } from 'react'; | ||
|
||
export default function ConfigQrCode() { | ||
const getUrl = useFetchConfigUrl(); | ||
const url = useAppSelector(urlConfigSelector); | ||
useEffect(() => getUrl(), [getUrl]); | ||
return ( | ||
<figure> | ||
{!url && <Loading />} | ||
{url && <QRCode value={url} />} | ||
</figure> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
removeNotification, | ||
selectNotifications, | ||
useAppDispatch, | ||
useAppSelector, | ||
} from '../store'; | ||
import { Alert, Button, Toast } from 'react-daisyui'; | ||
import { useCallback } from 'react'; | ||
import { X } from 'react-feather'; | ||
|
||
export function Notification() { | ||
const notifications = useAppSelector(selectNotifications); | ||
const dispatch = useAppDispatch(); | ||
const remove = useCallback( | ||
(msg: string) => () => { | ||
dispatch(removeNotification(msg)); | ||
}, | ||
[dispatch] | ||
); | ||
return ( | ||
<div className=""> | ||
{notifications.map((message, index) => ( | ||
<Toast horizontal="start" vertical="bottom" key={index}> | ||
<Alert status="error"> | ||
<Button | ||
onClick={remove(message)} | ||
color="ghost" | ||
size="sm" | ||
shape="circle" | ||
> | ||
<X /> | ||
</Button> | ||
<span>{message}</span> | ||
</Alert> | ||
</Toast> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export async function setupLogging() { | ||
const log = await import('electron-log/renderer'); | ||
console.log = log.log; | ||
console.debug = log.debug; | ||
console.error = log.error; | ||
console.warn = log.warn; | ||
console.trace = log.verbose; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const isElectron: boolean = window.electron !== undefined; | ||
export const isDev: boolean = import.meta.env.DEV; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useCallback } from 'react'; | ||
import { fetchConfigUrl } from './thunks'; | ||
import { useAppDispatch } from './types'; | ||
|
||
export function useFetchConfigUrl() { | ||
const dispatch = useAppDispatch(); | ||
return useCallback(() => { | ||
dispatch(fetchConfigUrl()); | ||
}, [dispatch]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,6 @@ | ||
import { setupListeners } from '@reduxjs/toolkit/query'; | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import { emptySplitApi } from './emptyApi.ts'; | ||
|
||
export const store = configureStore({ | ||
reducer: { | ||
// Add the generated reducer as a specific top-level slice | ||
[emptySplitApi.reducerPath]: emptySplitApi.reducer, | ||
}, | ||
// Adding the api middleware enables caching, invalidation, polling, | ||
// and other useful features of `rtk-query`. | ||
middleware: (getDefaultMiddleware) => | ||
getDefaultMiddleware().concat(emptySplitApi.middleware), | ||
}); | ||
|
||
// optional, but required for refetchOnFocus/refetchOnReconnect behaviors | ||
// see `setupListeners` docs - takes an optional callback as the 2nd arg for customization | ||
setupListeners(store.dispatch); | ||
export * from './empty.api'; | ||
export * from './hooks'; | ||
export * from './store'; | ||
export * from './slices'; | ||
export * from './types'; | ||
export * from './thunks'; |
Oops, something went wrong.