fix(theme-editor): avoid error (#2340)
This commit is contained in:
parent
e7ade9ee12
commit
fd6d5ac2a6
@ -68,12 +68,12 @@ function Label() {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!currentUser?.data?.data?.systemSettings) {
|
||||
if (!currentUser) {
|
||||
error('Please check if provide `CurrentUserProvider` in your app.');
|
||||
throw new Error('Please check if provide `CurrentUserProvider` in your app.');
|
||||
}
|
||||
|
||||
if (!systemSettings?.data?.data?.options) {
|
||||
if (!systemSettings) {
|
||||
error('Please check if provide `SystemSettingsProvider` in your app.');
|
||||
throw new Error('Please check if provide `SystemSettingsProvider` in your app.');
|
||||
}
|
||||
|
@ -9,14 +9,14 @@ export function useUpdateThemeSettings() {
|
||||
|
||||
const updateUserThemeSettings = useCallback(
|
||||
async (themeId: number | null) => {
|
||||
if (themeId === currentUser.data.data.systemSettings.themeId) {
|
||||
if (themeId === currentUser.data.data.systemSettings?.themeId) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await api.resource('users').updateProfile({
|
||||
values: {
|
||||
systemSettings: {
|
||||
...currentUser.data.data.systemSettings,
|
||||
...(currentUser.data.data.systemSettings || {}),
|
||||
themeId,
|
||||
},
|
||||
},
|
||||
@ -25,7 +25,7 @@ export function useUpdateThemeSettings() {
|
||||
data: {
|
||||
...currentUser.data.data,
|
||||
systemSettings: {
|
||||
...currentUser.data.data.systemSettings,
|
||||
...(currentUser.data.data.systemSettings || {}),
|
||||
themeId,
|
||||
},
|
||||
},
|
||||
@ -39,7 +39,7 @@ export function useUpdateThemeSettings() {
|
||||
|
||||
const updateSystemThemeSettings = useCallback(
|
||||
async (themeId: number | null) => {
|
||||
if (themeId === systemSettings.data.data.options.themeId) {
|
||||
if (themeId === systemSettings.data.data.options?.themeId) {
|
||||
return;
|
||||
}
|
||||
await api.request({
|
||||
@ -47,7 +47,7 @@ export function useUpdateThemeSettings() {
|
||||
method: 'post',
|
||||
data: {
|
||||
options: {
|
||||
...systemSettings.data.data.options,
|
||||
...(systemSettings.data.data.options || {}),
|
||||
themeId,
|
||||
},
|
||||
},
|
||||
@ -56,7 +56,7 @@ export function useUpdateThemeSettings() {
|
||||
data: {
|
||||
...systemSettings.data.data,
|
||||
options: {
|
||||
...systemSettings.data.data.options,
|
||||
...(systemSettings.data.data.options || {}),
|
||||
themeId,
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user