@sonic-equipment/ui 0.0.107 → 0.0.108

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +8 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8322,14 +8322,18 @@ function Announcement({ announcement: { href, id, text, title, type }, onDismiss
8322
8322
  const now = () => new Date();
8323
8323
  function ConnectedAnnouncement({ announcement: { endDate, startDate, ...announcement }, onDismiss, }) {
8324
8324
  const [isVisible, setIsVisible] = useState((!startDate || startDate <= now()) && (!endDate || endDate > now()));
8325
+ const getIsVisible = useCallback(() => isVisible, [isVisible]);
8325
8326
  useEffect(() => {
8326
8327
  if (endDate && now() >= endDate)
8327
8328
  return;
8328
- const interval = setInterval(() => {
8329
- setIsVisible((!startDate || startDate <= now()) && (!endDate || endDate > now()));
8329
+ const intervalId = setInterval(() => {
8330
+ const isStillVisible = (!startDate || startDate <= now()) && (!endDate || endDate > now());
8331
+ if (getIsVisible() && !isStillVisible)
8332
+ clearInterval(intervalId);
8333
+ setIsVisible(isStillVisible);
8330
8334
  }, 1 * TIME.MINUTE);
8331
- return () => clearInterval(interval);
8332
- }, [endDate, startDate]);
8335
+ return () => clearInterval(intervalId);
8336
+ }, [endDate, getIsVisible, startDate]);
8333
8337
  if (!isVisible)
8334
8338
  return null;
8335
8339
  return jsx(Announcement, { announcement: announcement, onDismiss: onDismiss });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {