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