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