(props: {
superstate: Superstate;
path: string;
})
| 141 | }; |
| 142 | |
| 143 | export const PathStickerContainer = (props: { |
| 144 | superstate: Superstate; |
| 145 | path: string; |
| 146 | }) => { |
| 147 | const [cache, setCache] = useState<PathState>(null); |
| 148 | const reloadCache = () => { |
| 149 | setCache(props.superstate.pathsIndex.get(props.path)); |
| 150 | }; |
| 151 | const reloadIcon = (payload: { path: string }) => { |
| 152 | if (payload.path == props.path) { |
| 153 | reloadCache(); |
| 154 | } |
| 155 | }; |
| 156 | |
| 157 | useEffect(() => { |
| 158 | reloadCache(); |
| 159 | props.superstate.eventsDispatcher.addListener( |
| 160 | "pathStateUpdated", |
| 161 | reloadIcon |
| 162 | ); |
| 163 | |
| 164 | return () => { |
| 165 | props.superstate.eventsDispatcher.removeListener( |
| 166 | "pathStateUpdated", |
| 167 | reloadIcon |
| 168 | ); |
| 169 | }; |
| 170 | }, [props.path]); |
| 171 | |
| 172 | return cache ? ( |
| 173 | <PathStickerView |
| 174 | superstate={props.superstate} |
| 175 | pathState={cache} |
| 176 | editable={true} |
| 177 | /> |
| 178 | ) : ( |
| 179 | <></> |
| 180 | ); |
| 181 | }; |
nothing calls this directly
no test coverage detected