yohei0125 3 лет назад
Родитель
Сommit
a911aa8511
1 измененных файлов с 9 добавлено и 5 удалено
  1. 9 5
      packages/app/src/components/PageAlert/PageRedirectedAlert.tsx

+ 9 - 5
packages/app/src/components/PageAlert/PageRedirectedAlert.tsx

@@ -2,6 +2,7 @@ import React, { useState, useCallback } from 'react';
 
 import { useTranslation } from 'next-i18next';
 
+import { toastError } from '~/client/util/apiNotification';
 import { useCurrentPagePath } from '~/stores/context';
 import { useRedirectFrom } from '~/stores/page-redirect';
 
@@ -12,12 +13,15 @@ export const PageRedirectedAlert = React.memo((): JSX.Element => {
 
   const [isUnlinked, setIsUnlinked] = useState(false);
 
-  const unlinkButtonClickHandler = useCallback(() => {
+  const unlinkButtonClickHandler = useCallback(async() => {
     if (currentPagePath == null) return;
-
-    unlink(currentPagePath);
-    setIsUnlinked(true);
-
+    try {
+      await unlink(currentPagePath);
+      setIsUnlinked(true);
+    }
+    catch (err) {
+      toastError(err);
+    }
   }, [currentPagePath, unlink]);
 
   if (redirectFrom == null) {