-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
15 changed files
with
391 additions
and
339 deletions.
There are no files selected for viewing
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
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 was deleted.
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { atom, selector } from "recoil"; | ||
|
||
type AutoInfo = { | ||
/** | ||
* Whether auto forward is enabled | ||
*/ | ||
enabled: boolean, | ||
/** | ||
* Time in seconds to wait before auto forwarding | ||
*/ | ||
time: number, | ||
/** | ||
* Force recheck the auto forward | ||
*/ | ||
update: number, | ||
} | ||
|
||
const autoInfoAtomState = atom<AutoInfo>({ | ||
key: 'autoInfoAtomState', | ||
default: { | ||
enabled: false, | ||
time: 1, | ||
update: 0, | ||
}, | ||
}); | ||
|
||
export const autoInfoState = selector<AutoInfo>({ | ||
key: 'autoInfoState', | ||
get: ({ get }) => { | ||
let time: number | undefined = undefined | ||
try { | ||
let v = localStorage.getItem("auto_forward_second") | ||
if (v) { | ||
time = parseInt(v) | ||
} | ||
} catch (e) { } | ||
|
||
let info = get(autoInfoAtomState) | ||
return { | ||
...info, | ||
time: time || info.time, | ||
} | ||
}, | ||
set: ({ set }, value) => { | ||
if (value.hasOwnProperty("time")) { | ||
localStorage.setItem("auto_forward_second", (value as AutoInfo).time.toString()) | ||
} | ||
set(autoInfoAtomState, value) | ||
}, | ||
}); |
Oops, something went wrong.