|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | import { useLayoutEffect, useRef } from 'react';
|
|---|
| 2 | import { useAppDispatch } from './hooks';
|
|---|
| 3 | import { addTooltipEntrySettings, removeTooltipEntrySettings, replaceTooltipEntrySettings } from './tooltipSlice';
|
|---|
| 4 | import { useIsPanorama } from '../context/PanoramaContext';
|
|---|
| 5 | export function SetTooltipEntrySettings(_ref) {
|
|---|
| 6 | var {
|
|---|
| 7 | tooltipEntrySettings
|
|---|
| 8 | } = _ref;
|
|---|
| 9 | var dispatch = useAppDispatch();
|
|---|
| 10 | var isPanorama = useIsPanorama();
|
|---|
| 11 | var prevSettingsRef = useRef(null);
|
|---|
| 12 | useLayoutEffect(() => {
|
|---|
| 13 | if (isPanorama) {
|
|---|
| 14 | // Panorama graphical items should never contribute to Tooltip payload.
|
|---|
| 15 | return;
|
|---|
| 16 | }
|
|---|
| 17 | if (prevSettingsRef.current === null) {
|
|---|
| 18 | dispatch(addTooltipEntrySettings(tooltipEntrySettings));
|
|---|
| 19 | } else if (prevSettingsRef.current !== tooltipEntrySettings) {
|
|---|
| 20 | dispatch(replaceTooltipEntrySettings({
|
|---|
| 21 | prev: prevSettingsRef.current,
|
|---|
| 22 | next: tooltipEntrySettings
|
|---|
| 23 | }));
|
|---|
| 24 | }
|
|---|
| 25 | prevSettingsRef.current = tooltipEntrySettings;
|
|---|
| 26 | }, [tooltipEntrySettings, dispatch, isPanorama]);
|
|---|
| 27 | useLayoutEffect(() => {
|
|---|
| 28 | return () => {
|
|---|
| 29 | if (prevSettingsRef.current) {
|
|---|
| 30 | dispatch(removeTooltipEntrySettings(prevSettingsRef.current));
|
|---|
| 31 | prevSettingsRef.current = null;
|
|---|
| 32 | }
|
|---|
| 33 | };
|
|---|
| 34 | }, [dispatch]);
|
|---|
| 35 | return null;
|
|---|
| 36 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.