|
1 |
| -import React, { useEffect, useState } from 'react' |
| 1 | +import React from 'react' |
2 | 2 | import { bool, func, number, object, string } from 'prop-types'
|
3 | 3 | import Tooltip from '@material-ui/core/Tooltip'
|
4 | 4 | import Typography from '@material-ui/core/Typography'
|
@@ -86,24 +86,11 @@ export const Plot = ({
|
86 | 86 | const isCrop =
|
87 | 87 | plotContent && getPlotContentType(plotContent) === itemType.CROP
|
88 | 88 | const isScarecow = itemsMap[plotContent?.itemId]?.type === itemType.SCARECROW
|
89 |
| - const [wasJustShoveled, setWasJustShoveled] = useState(false) |
90 |
| - const [initialIsShoveledState, setInitialIsShoveledState] = useState( |
91 |
| - Boolean(plotContent?.isShoveled) |
92 |
| - ) |
93 |
| - |
94 |
| - useEffect(() => { |
95 |
| - if ( |
96 |
| - !initialIsShoveledState && |
97 |
| - plotContent?.isShoveled && |
98 |
| - plotContent?.oreId |
99 |
| - ) { |
100 |
| - setWasJustShoveled(true) |
101 |
| - } |
102 |
| - }, [initialIsShoveledState, plotContent]) |
103 | 89 |
|
104 |
| - useEffect(() => { |
105 |
| - if (plotContent === null) setInitialIsShoveledState(false) |
106 |
| - }, [plotContent]) |
| 90 | + let wasJustShoveled = false |
| 91 | + if (plotContent && plotContent.wasJustShoveled) { |
| 92 | + wasJustShoveled = true |
| 93 | + } |
107 | 94 |
|
108 | 95 | const showPlotImage = Boolean(
|
109 | 96 | image &&
|
@@ -145,14 +132,9 @@ export const Plot = ({
|
145 | 132 | <img
|
146 | 133 | {...{
|
147 | 134 | className: classNames('square', {
|
148 |
| - ...(isCrop && { |
149 |
| - animated: isRipe, |
150 |
| - heartBeat: isRipe, |
151 |
| - }), |
152 |
| - ...(wasJustShoveled && { |
153 |
| - animated: true, |
154 |
| - 'was-just-shoveled': true, |
155 |
| - }), |
| 135 | + animated: wasJustShoveled || (isCrop && isRipe), |
| 136 | + heartBeat: isCrop && isRipe, |
| 137 | + 'was-just-shoveled': wasJustShoveled, |
156 | 138 | }),
|
157 | 139 | style: {
|
158 | 140 | backgroundImage: showPlotImage ? `url(${image})` : undefined,
|
|
0 commit comments