فهرست منبع

rename variable and method

kaori 3 سال پیش
والد
کامیت
fccd5f53dc
2فایلهای تغییر یافته به همراه7 افزوده شده و 8 حذف شده
  1. 5 2
      packages/app/src/components/Me/BasicInfoSettings.tsx
  2. 2 6
      packages/app/src/stores/personal-settings.tsx

+ 5 - 2
packages/app/src/components/Me/BasicInfoSettings.tsx

@@ -18,10 +18,11 @@ const BasicInfoSettings = (props: Props) => {
   const { appContainer } = props;
   const { appContainer } = props;
 
 
   const {
   const {
+    data: personalSettingsDataFromDB,
     mutate: mutateDatabaseData,
     mutate: mutateDatabaseData,
   } = useSWRxPersonalSettings();
   } = useSWRxPersonalSettings();
   const {
   const {
-    data: personalSettingsInfo, mutate, sync, update, error, personalSettingsDataFromDB,
+    data: personalSettingsInfo, mutate, sync, updateBasicInfo, error,
   } = usePersonalSettings();
   } = usePersonalSettings();
 
 
   useEffect(() => {
   useEffect(() => {
@@ -32,8 +33,10 @@ const BasicInfoSettings = (props: Props) => {
   const submitHandler = async() => {
   const submitHandler = async() => {
 
 
     try {
     try {
-      update();
+      updateBasicInfo();
+      // revaridate
       mutateDatabaseData();
       mutateDatabaseData();
+      sync();
       toastSuccess(t('toaster.update_successed', { target: t('Basic Info') }));
       toastSuccess(t('toaster.update_successed', { target: t('Basic Info') }));
     }
     }
     catch (err) {
     catch (err) {

+ 2 - 6
packages/app/src/stores/personal-settings.tsx

@@ -1,7 +1,5 @@
 import useSWR, { SWRResponse } from 'swr';
 import useSWR, { SWRResponse } from 'swr';
 
 
-
-import { Nullable } from '~/interfaces/common';
 import { IExternalAccount } from '~/interfaces/external-account';
 import { IExternalAccount } from '~/interfaces/external-account';
 import { IUser } from '~/interfaces/user';
 import { IUser } from '~/interfaces/user';
 
 
@@ -18,9 +16,8 @@ export const useSWRxPersonalSettings = (): SWRResponse<IUser, Error> => {
 };
 };
 
 
 export type IPersonalSettingsInfoOption = {
 export type IPersonalSettingsInfoOption = {
-  personalSettingsDataFromDB: Nullable<IUser>,
   sync: () => void,
   sync: () => void,
-  update: () => void,
+  updateBasicInfo: () => void,
 }
 }
 
 
 export const usePersonalSettings = (): SWRResponse<IUser, Error> & IPersonalSettingsInfoOption => {
 export const usePersonalSettings = (): SWRResponse<IUser, Error> & IPersonalSettingsInfoOption => {
@@ -30,14 +27,13 @@ export const usePersonalSettings = (): SWRResponse<IUser, Error> & IPersonalSett
 
 
   return {
   return {
     ...swrResult,
     ...swrResult,
-    personalSettingsDataFromDB,
 
 
     // Sync with database
     // Sync with database
     sync: (): void => {
     sync: (): void => {
       const { mutate } = swrResult;
       const { mutate } = swrResult;
       mutate(personalSettingsDataFromDB);
       mutate(personalSettingsDataFromDB);
     },
     },
-    update: () => {
+    updateBasicInfo: () => {
       const { data } = swrResult;
       const { data } = swrResult;
 
 
       if (data == null) {
       if (data == null) {