-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/dynamic settings #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6358fcd
5f9df0e
ae90114
d57a4b2
173b87d
c6659f5
c598713
bff19c6
ab93f81
bd4d9ab
88d474d
5c4fbaa
1f6aaae
3a66173
682efb7
13549d1
dd4da64
9726a47
ae7258b
4c592f3
9e98706
f13a1b0
6395a83
a232f40
adb221e
51f610b
9ebbffd
62da92a
1522801
6fb3163
24a8a4a
ef9fa41
45f7cfd
fcbd7e4
cb297de
618c2cb
54fc02f
1393b93
613d9ce
f0787b2
ecc5f79
be0b5c2
08ce579
a82d97d
87e81b6
32ceb22
5f6c36e
0b7bad9
f0efe79
99e6f6b
32ac505
4fd5e25
af5006e
4a23d49
0cf1998
31e4a82
c13300c
8745802
2b0f880
dac0e60
b42a625
cdb67d4
46d8bd3
ab061fb
148fe12
1571e10
2b559e7
6e822b0
08b9b5a
9f454a0
4420832
6a2886d
7f265bb
ba377fe
14d4087
f34381b
6eb8148
16c2642
2ded0c4
4f1cdee
139b6dd
a13ceb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||||||||||||
| import React, { createContext, useContext } from 'react'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| import { useSettings } from '@hooks/persisted/useSettings'; | ||||||||||||||||||||
| import { defaultSettings } from '@screens/settings/constants/defaultValues'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| type SettingsContextType = ReturnType<typeof useSettings>; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const defaultValue = defaultSettings as any as SettingsContextType; | ||||||||||||||||||||
| const SettingsContext = createContext<SettingsContextType>(defaultValue); | ||||||||||||||||||||
|
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provide a safe default context value (remove Current default casts -const defaultValue = defaultSettings as any as SettingsContextType;
+const defaultValue: SettingsContextType = {
+ ...defaultSettings,
+ setSettings: () => {},
+ saveCustomReaderTheme: () => {},
+ deleteCustomReaderTheme: () => {},
+};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| export function SettingsContextProvider({ | ||||||||||||||||||||
| children, | ||||||||||||||||||||
| }: { | ||||||||||||||||||||
| children: React.ReactNode; | ||||||||||||||||||||
| }) { | ||||||||||||||||||||
| const settings = useSettings(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| return ( | ||||||||||||||||||||
| <SettingsContext.Provider value={settings}> | ||||||||||||||||||||
| {children} | ||||||||||||||||||||
| </SettingsContext.Provider> | ||||||||||||||||||||
| ); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export const useSettingsContext = (): SettingsContextType => { | ||||||||||||||||||||
| return useContext(SettingsContext); | ||||||||||||||||||||
| }; | ||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fallback when backgroundColor is missing; keep compatibility with theme
If
settings.backgroundColoris undefined, CSS var becomes empty. Provide safe fallback to priortheme.📝 Committable suggestion
🤖 Prompt for AI Agents