Remove notices after 5 seconds

[MAILPOET-2652]
This commit is contained in:
Pavel Dohnal
2020-01-23 16:25:10 +01:00
committed by Jack Kitterhing
parent fb3f132b29
commit c13dcfa380

View File

@@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { memoize } from 'lodash';
import { NoticeList } from '@wordpress/components'; import { NoticeList } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data'; import { useDispatch, useSelect } from '@wordpress/data';
@@ -13,6 +14,11 @@ export default () => {
); );
const { removeNotice } = useDispatch('mailpoet-form-editor'); const { removeNotice } = useDispatch('mailpoet-form-editor');
const timedRemove = memoize((noticeId) => {
setTimeout(() => removeNotice(noticeId), 5000);
});
dismissibleNotices.forEach((notice) => timedRemove(notice.id));
return ( return (
<> <>