refacto notifications redirection
This commit is contained in:
parent
4cf0bdb1e8
commit
15ec6037c1
@ -34,7 +34,7 @@ export default function Navigation() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getNotifications = useCallback(async () => {
|
const getNotifications = useCallback(async () => {
|
||||||
await getAnchoringStatus();
|
//await getAnchoringStatus();
|
||||||
const notifications = await Notifications.getInstance().get({
|
const notifications = await Notifications.getInstance().get({
|
||||||
where: {
|
where: {
|
||||||
read: false,
|
read: false,
|
||||||
@ -47,11 +47,12 @@ export default function Navigation() {
|
|||||||
redirectUrl: notification.notification.redirection_url,
|
redirectUrl: notification.notification.redirection_url,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, [getAnchoringStatus]);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
getAnchoringStatus();
|
||||||
getNotifications();
|
getNotifications();
|
||||||
}, [pathname, getNotifications]);
|
}, [pathname, getNotifications, getAnchoringStatus]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes["root"]}>
|
<div className={classes["root"]}>
|
||||||
|
@ -108,10 +108,12 @@ class ToastElementClass extends React.Component<IPropsClass, IState> {
|
|||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleClick(e: React.MouseEvent) {
|
private async handleClick(e: React.MouseEvent) {
|
||||||
|
console.log('redirectUrl', this.props.toast.redirectUrl);
|
||||||
if (this.props.toast.redirectUrl) {
|
if (this.props.toast.redirectUrl) {
|
||||||
this.props.router.push(this.props.toast.redirectUrl);
|
|
||||||
this.onClose(e);
|
this.onClose(e);
|
||||||
|
await this.props.router.push(this.props.toast.redirectUrl);
|
||||||
|
this.props.router.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ type IProps = {};
|
|||||||
type IState = {
|
type IState = {
|
||||||
toastList: IToast[];
|
toastList: IToast[];
|
||||||
};
|
};
|
||||||
export default class ToastsContainer extends React.Component<IProps, IState> {
|
export class ToastsContainerClass extends React.Component<IProps, IState> {
|
||||||
private removeOnChange = () => {};
|
private removeOnChange = () => {};
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps) {
|
||||||
@ -25,7 +25,7 @@ export default class ToastsContainer extends React.Component<IProps, IState> {
|
|||||||
<div className={classNames(classes["root"], this.state.toastList.length > 0 && classes["open"])}>
|
<div className={classNames(classes["root"], this.state.toastList.length > 0 && classes["open"])}>
|
||||||
<>
|
<>
|
||||||
{this.state.toastList.map((toast) => {
|
{this.state.toastList.map((toast) => {
|
||||||
return <ToastElement toast={toast} key={toast.id} />;
|
return <ToastElement toast={toast} key={toast.id}/>;
|
||||||
})}
|
})}
|
||||||
</>
|
</>
|
||||||
</div>
|
</div>
|
||||||
@ -44,3 +44,7 @@ export default class ToastsContainer extends React.Component<IProps, IState> {
|
|||||||
this.setState({ toastList });
|
this.setState({ toastList });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function ToastsContainer(props: IProps) {
|
||||||
|
return <ToastsContainerClass {...props}/>;
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user