Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
1857362d
Commit
1857362d
authored
Jan 17, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: locale and appearance setting
parent
6d7186fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
App.tsx
web/src/App.tsx
+14
-4
PreferencesSection.tsx
web/src/components/Settings/PreferencesSection.tsx
+2
-3
No files found.
web/src/App.tsx
View file @
1857362d
...
...
@@ -16,6 +16,7 @@ const App = () => {
const
userStore
=
useUserStore
();
const
[
loading
,
setLoading
]
=
useState
(
true
);
const
{
appearance
,
locale
,
systemStatus
}
=
globalStore
.
state
;
const
userSetting
=
userStore
.
userSetting
;
// Redirect to sign up page if no host.
useEffect
(()
=>
{
...
...
@@ -81,9 +82,18 @@ const App = () => {
link
.
href
=
systemStatus
.
customizedProfile
.
logoUrl
||
"/logo.webp"
;
},
[
systemStatus
.
customizedProfile
]);
useEffect
(()
=>
{
if
(
!
userSetting
)
{
return
;
}
globalStore
.
setLocale
(
userSetting
.
locale
);
globalStore
.
setAppearance
(
userSetting
.
appearance
as
Appearance
);
},
[
userSetting
?.
locale
,
userSetting
?.
appearance
]);
useEffect
(()
=>
{
const
{
locale
:
storageLocale
}
=
storage
.
get
([
"locale"
]);
const
currentLocale
=
userStore
.
userSetting
?.
locale
||
storageLocale
||
locale
;
const
currentLocale
=
storageLocale
||
locale
;
i18n
.
changeLanguage
(
currentLocale
);
document
.
documentElement
.
setAttribute
(
"lang"
,
currentLocale
);
if
(
currentLocale
===
"ar"
)
{
...
...
@@ -94,11 +104,11 @@ const App = () => {
storage
.
set
({
locale
:
currentLocale
,
});
},
[
locale
,
userStore
.
userSetting
?.
locale
]);
},
[
locale
]);
useEffect
(()
=>
{
const
{
appearance
:
storageAppearance
}
=
storage
.
get
([
"appearance"
]);
let
currentAppearance
=
(
userStore
.
userSetting
?.
appearance
||
storageAppearance
||
appearance
)
as
Appearance
;
let
currentAppearance
=
(
storageAppearance
||
appearance
)
as
Appearance
;
if
(
currentAppearance
===
"system"
)
{
currentAppearance
=
getSystemColorScheme
();
}
...
...
@@ -106,7 +116,7 @@ const App = () => {
storage
.
set
({
appearance
:
currentAppearance
,
});
},
[
appearance
,
userStore
.
userSetting
?.
appearance
]);
},
[
appearance
]);
useEffect
(()
=>
{
const
root
=
document
.
documentElement
;
...
...
web/src/components/Settings/PreferencesSection.tsx
View file @
1857362d
...
...
@@ -18,7 +18,6 @@ const PreferencesSection = () => {
const
t
=
useTranslate
();
const
globalStore
=
useGlobalStore
();
const
userStore
=
useUserStore
();
const
{
appearance
,
locale
}
=
globalStore
.
state
;
const
setting
=
userStore
.
userSetting
as
UserSetting
;
const
[
telegramUserId
,
setTelegramUserId
]
=
useState
<
string
>
(
setting
.
telegramUserId
);
...
...
@@ -75,11 +74,11 @@ const PreferencesSection = () => {
<
p
className=
"font-medium text-gray-700 dark:text-gray-500"
>
{
t
(
"common.basic"
)
}
</
p
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
span
>
{
t
(
"common.language"
)
}
</
span
>
<
LocaleSelect
value=
{
locale
}
onChange=
{
handleLocaleSelectChange
}
/>
<
LocaleSelect
value=
{
setting
.
locale
}
onChange=
{
handleLocaleSelectChange
}
/>
</
div
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
span
>
{
t
(
"setting.preference-section.theme"
)
}
</
span
>
<
AppearanceSelect
value=
{
a
ppearance
}
onChange=
{
handleAppearanceSelectChange
}
/>
<
AppearanceSelect
value=
{
setting
.
appearance
as
A
ppearance
}
onChange=
{
handleAppearanceSelectChange
}
/>
</
div
>
<
p
className=
"font-medium text-gray-700 dark:text-gray-500"
>
{
t
(
"setting.preference"
)
}
</
p
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment