-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
4a87ea5
commit 315c87d
Showing
37 changed files
with
299 additions
and
420 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 +1,11 @@ | ||
import { RouterProvider } from 'react-router-dom' | ||
import { RecoilRoot } from 'recoil' | ||
import { Provider } from 'jotai' | ||
import { router } from './router' | ||
|
||
export function App() { | ||
return ( | ||
<RecoilRoot> | ||
<Provider> | ||
<RouterProvider router={router} /> | ||
</RecoilRoot> | ||
</Provider> | ||
) | ||
} |
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,50 +1,40 @@ | ||
import { getOrElse } from 'fp-ts/lib/Either' | ||
import { pipe } from 'fp-ts/lib/function' | ||
import { atom, selector } from 'recoil' | ||
import { ffetch } from '../lib/httpClient' | ||
import { CustomTemplate } from '../types' | ||
import { serverSideCookiesState, serverURL } from './settings' | ||
import { atom } from 'jotai' | ||
import { atomWithStorage } from 'jotai/utils' | ||
|
||
export const cookiesTemplateState = selector({ | ||
key: 'cookiesTemplateState', | ||
get: ({ get }) => get(serverSideCookiesState) | ||
export const cookiesTemplateState = atom<Promise<string>>(async (get) => | ||
await get(serverSideCookiesState) | ||
? '--cookies=cookies.txt' | ||
: '' | ||
}) | ||
) | ||
|
||
export const customArgsState = atom({ | ||
key: 'customArgsState', | ||
default: localStorage.getItem('customArgs') ?? '', | ||
effects: [ | ||
({ onSet }) => onSet(e => localStorage.setItem('customArgs', e)) | ||
] | ||
}) | ||
export const customArgsState = atomWithStorage( | ||
'customArgs', | ||
localStorage.getItem('customArgs') ?? '' | ||
) | ||
|
||
export const filenameTemplateState = atom({ | ||
key: 'filenameTemplateState', | ||
default: localStorage.getItem('lastFilenameTemplate') ?? '', | ||
effects: [ | ||
({ onSet }) => onSet(e => localStorage.setItem('lastFilenameTemplate', e)) | ||
] | ||
}) | ||
export const filenameTemplateState = atomWithStorage( | ||
'lastFilenameTemplate', | ||
localStorage.getItem('lastFilenameTemplate') ?? '' | ||
) | ||
|
||
export const downloadTemplateState = selector({ | ||
key: 'downloadTemplateState', | ||
get: ({ get }) => | ||
`${get(customArgsState)} ${get(cookiesTemplateState)}` | ||
.replace(/ +/g, ' ') | ||
.trim() | ||
}) | ||
export const downloadTemplateState = atom<string>((get) => | ||
`${get(customArgsState)} ${get(cookiesTemplateState)}` | ||
.replace(/ +/g, ' ') | ||
.trim() | ||
) | ||
|
||
export const savedTemplatesState = selector<CustomTemplate[]>({ | ||
key: 'savedTemplatesState', | ||
get: async ({ get }) => { | ||
const task = ffetch<CustomTemplate[]>(`${get(serverURL)}/api/v1/template/all`) | ||
const either = await task() | ||
export const savedTemplatesState = atom<Promise<CustomTemplate[]>>(async (get) => { | ||
const task = ffetch<CustomTemplate[]>(`${get(serverURL)}/api/v1/template/all`) | ||
const either = await task() | ||
|
||
return pipe( | ||
either, | ||
getOrElse(() => new Array<CustomTemplate>()) | ||
) | ||
} | ||
}) | ||
return pipe( | ||
either, | ||
getOrElse(() => new Array<CustomTemplate>()) | ||
) | ||
} | ||
) |
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,22 +1,13 @@ | ||
import * as O from 'fp-ts/Option' | ||
import { pipe } from 'fp-ts/lib/function' | ||
import { atom, selector } from 'recoil' | ||
import { RPCResult } from '../types' | ||
import { atom } from 'jotai' | ||
|
||
export const downloadsState = atom<O.Option<RPCResult[]>>({ | ||
key: 'downloadsState', | ||
default: O.none | ||
}) | ||
export const downloadsState = atom<O.Option<RPCResult[]>>(O.none) | ||
|
||
export const loadingDownloadsState = selector<boolean>({ | ||
key: 'loadingDownloadsState', | ||
get: ({ get }) => O.isNone(get(downloadsState)) | ||
}) | ||
export const loadingDownloadsState = atom<boolean>((get) => O.isNone(get(downloadsState))) | ||
|
||
export const activeDownloadsState = selector<RPCResult[]>({ | ||
key: 'activeDownloadsState', | ||
get: ({ get }) => pipe( | ||
get(downloadsState), | ||
O.getOrElse(() => new Array<RPCResult>()) | ||
) | ||
}) | ||
export const activeDownloadsState = atom<RPCResult[]>((get) => pipe( | ||
get(downloadsState), | ||
O.getOrElse(() => new Array<RPCResult>()) | ||
)) |
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,9 +1,5 @@ | ||
import { selector } from 'recoil' | ||
import { atom } from 'jotai' | ||
import I18nBuilder from '../lib/intl' | ||
import { languageState } from './settings' | ||
|
||
export const i18nBuilderState = selector({ | ||
key: 'i18nBuilderState', | ||
get: ({ get }) => new I18nBuilder(get(languageState)), | ||
dangerouslyAllowMutability: true, | ||
}) | ||
export const i18nBuilderState = atom((get) => new I18nBuilder(get(languageState))) |
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,23 +1,17 @@ | ||
import { atom, selector } from 'recoil' | ||
import { atom } from 'jotai' | ||
import { RPCClient } from '../lib/rpcClient' | ||
import { rpcHTTPEndpoint, rpcWebSocketEndpoint } from './settings' | ||
import { atomWithStorage } from 'jotai/utils' | ||
|
||
export const rpcClientState = selector({ | ||
key: 'rpcClientState', | ||
get: ({ get }) => | ||
new RPCClient( | ||
get(rpcHTTPEndpoint), | ||
get(rpcWebSocketEndpoint), | ||
localStorage.getItem('token') ?? '' | ||
), | ||
dangerouslyAllowMutability: true, | ||
}) | ||
export const rpcClientState = atom((get) => | ||
new RPCClient( | ||
get(rpcHTTPEndpoint), | ||
get(rpcWebSocketEndpoint), | ||
localStorage.getItem('token') ?? '' | ||
), | ||
) | ||
|
||
export const rpcPollingTimeState = atom({ | ||
key: 'rpcPollingTimeState', | ||
default: Number(localStorage.getItem('rpc-polling-time')) || 1000, | ||
effects: [ | ||
({ onSet }) => | ||
onSet(a => localStorage.setItem('rpc-polling-time', a.toString())) | ||
] | ||
}) | ||
export const rpcPollingTimeState = atomWithStorage( | ||
'rpc-polling-time', | ||
Number(localStorage.getItem('rpc-polling-time')) || 1000 | ||
) |
Oops, something went wrong.