Kaynağa Gözat

adjust toaster

itizawa 6 yıl önce
ebeveyn
işleme
18cbb324f2

+ 7 - 2
src/client/js/components/Me/BasicInfoSettings.jsx

@@ -21,8 +21,13 @@ class BasicInfoSettings extends React.Component {
     this.onClickSubmit = this.onClickSubmit.bind(this);
     this.onClickSubmit = this.onClickSubmit.bind(this);
   }
   }
 
 
-  componentDidMount() {
-    this.props.personalContainer.retrievePersonalData();
+  async componentDidMount() {
+    try {
+      await this.props.personalContainer.retrieveExternalAccounts();
+    }
+    catch (err) {
+      toastError(err);
+    }
   }
   }
 
 
   async onClickSubmit() {
   async onClickSubmit() {

+ 8 - 1
src/client/js/components/Me/ExternalAccountLinkedMe.jsx

@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 import { withTranslation } from 'react-i18next';
 
 
 import { createSubscribedElement } from '../UnstatedUtils';
 import { createSubscribedElement } from '../UnstatedUtils';
+import { toastError } from '../../util/apiNotification';
+
 import AppContainer from '../../services/AppContainer';
 import AppContainer from '../../services/AppContainer';
 import PersonalContainer from '../../services/PersonalContainer';
 import PersonalContainer from '../../services/PersonalContainer';
 import ExternalAccountRow from './ExternalAccountRow';
 import ExternalAccountRow from './ExternalAccountRow';
@@ -11,7 +13,12 @@ import ExternalAccountRow from './ExternalAccountRow';
 class ExternalAccountLinkedMe extends React.Component {
 class ExternalAccountLinkedMe extends React.Component {
 
 
   async componentDidMount() {
   async componentDidMount() {
-    this.props.personalContainer.retrieveExternalAccounts();
+    try {
+      await this.props.personalContainer.retrieveExternalAccounts();
+    }
+    catch (err) {
+      toastError(err);
+    }
   }
   }
 
 
   render() {
   render() {

+ 4 - 6
src/client/js/services/PersonalContainer.js

@@ -2,8 +2,6 @@ import { Container } from 'unstated';
 
 
 import loggerFactory from '@alias/logger';
 import loggerFactory from '@alias/logger';
 
 
-import { toastError } from '../util/apiNotification';
-
 // eslint-disable-next-line no-unused-vars
 // eslint-disable-next-line no-unused-vars
 const logger = loggerFactory('growi:services:PersonalContainer');
 const logger = loggerFactory('growi:services:PersonalContainer');
 
 
@@ -53,9 +51,9 @@ export default class PersonalContainer extends Container {
       });
       });
     }
     }
     catch (err) {
     catch (err) {
-      this.setState({ retrieveError: err.message });
+      this.setState({ retrieveError: err });
       logger.error(err);
       logger.error(err);
-      toastError(new Error('Failed to fetch data'));
+      throw new Error('Failed to fetch personal data');
     }
     }
   }
   }
 
 
@@ -70,9 +68,9 @@ export default class PersonalContainer extends Container {
       this.setState({ externalAccounts });
       this.setState({ externalAccounts });
     }
     }
     catch (err) {
     catch (err) {
-      this.setState({ retrieveError: err.message });
+      this.setState({ retrieveError: err });
       logger.error(err);
       logger.error(err);
-      toastError(new Error('Failed to fetch data'));
+      throw new Error('Failed to fetch external accounts');
     }
     }
   }
   }
 
 

+ 19 - 19
src/server/routes/apiv3/personal-setting.js

@@ -52,25 +52,25 @@ module.exports = (crowi) => {
   });
   });
 
 
   /**
   /**
- * @swagger
- *
- *    /personal-setting/external-accounts:
- *      get:
- *        tags: [PersonalSetting]
- *        operationId: getExternalAccounts
- *        summary: /personal-setting/external-accounts
- *        description: Get external accounts that linked current user
- *        responses:
- *          200:
- *            description: external accounts
- *            content:
- *              application/json:
- *                schema:
- *                  externalAccounts:
- *                    currentUser:
- *                      type: object
- *                      description: array of external accounts
- */
+   * @swagger
+   *
+   *    /personal-setting/external-accounts:
+   *      get:
+   *        tags: [PersonalSetting]
+   *        operationId: getExternalAccounts
+   *        summary: /personal-setting/external-accounts
+   *        description: Get external accounts that linked current user
+   *        responses:
+   *          200:
+   *            description: external accounts
+   *            content:
+   *              application/json:
+   *                schema:
+   *                  externalAccounts:
+   *                    currentUser:
+   *                      type: object
+   *                      description: array of external accounts
+   */
   router.get('/external-accounts', loginRequiredStrictly, async(req, res) => {
   router.get('/external-accounts', loginRequiredStrictly, async(req, res) => {
     const userData = req.user;
     const userData = req.user;