refacto notifications redirection

This commit is contained in:
OxSaitama 2023-10-03 16:56:32 +02:00
parent 4cf0bdb1e8
commit 15ec6037c1
3 changed files with 14 additions and 7 deletions

View File

@ -34,7 +34,7 @@ export default function Navigation() {
}, []);
const getNotifications = useCallback(async () => {
await getAnchoringStatus();
//await getAnchoringStatus();
const notifications = await Notifications.getInstance().get({
where: {
read: false,
@ -47,11 +47,12 @@ export default function Navigation() {
redirectUrl: notification.notification.redirection_url,
});
});
}, [getAnchoringStatus]);
}, []);
useEffect(() => {
getAnchoringStatus();
getNotifications();
}, [pathname, getNotifications]);
}, [pathname, getNotifications, getAnchoringStatus]);
return (
<div className={classes["root"]}>

View File

@ -108,10 +108,12 @@ class ToastElementClass extends React.Component<IPropsClass, IState> {
}, 200);
}
private handleClick(e: React.MouseEvent) {
private async handleClick(e: React.MouseEvent) {
console.log('redirectUrl', this.props.toast.redirectUrl);
if (this.props.toast.redirectUrl) {
this.props.router.push(this.props.toast.redirectUrl);
this.onClose(e);
await this.props.router.push(this.props.toast.redirectUrl);
this.props.router.reload();
}
}
}

View File

@ -8,7 +8,7 @@ type IProps = {};
type IState = {
toastList: IToast[];
};
export default class ToastsContainer extends React.Component<IProps, IState> {
export class ToastsContainerClass extends React.Component<IProps, IState> {
private removeOnChange = () => {};
public constructor(props: IProps) {
@ -44,3 +44,7 @@ export default class ToastsContainer extends React.Component<IProps, IState> {
this.setState({ toastList });
}
}
export default function ToastsContainer(props: IProps) {
return <ToastsContainerClass {...props}/>;
};