Skip to content

Commit

Permalink
fix: trigger props resend when iframe src changes [LIBS-488] #1344
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp committed Sep 28, 2023
2 parents fac501e + 7998fc8 commit cea7600
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [3.10.0-alpha.2](https://github.com/dhis2/app-runtime/compare/v3.10.0-alpha.1...v3.10.0-alpha.2) (2023-03-15)

### Bug Fixes

* add in plugin service in runtime package ([#1343](https://github.com/dhis2/app-runtime/issues/1343)) ([ed06a9f](https://github.com/dhis2/app-runtime/commit/ed06a9f4af7d3db40600ffd7e1b03cd095db36fc))

# [3.10.0-alpha.4](https://github.com/dhis2/app-runtime/compare/v3.10.0-alpha.3...v3.10.0-alpha.4) (2023-09-28)


Expand Down Expand Up @@ -37,6 +43,18 @@

### Bug Fixes

* add documentation, clean up ([c537590](https://github.com/dhis2/app-runtime/commit/c537590176b2e6aebf278653a87705b3417bcc38))
* clean up, add useless test ([b14952b](https://github.com/dhis2/app-runtime/commit/b14952b137971f625283c8de60afac061176b80e))
* custom error handling ([c72fc6e](https://github.com/dhis2/app-runtime/commit/c72fc6eac576ce043ab706e13030497a0dab3d3a))
* dependency resolution ([2480c1c](https://github.com/dhis2/app-runtime/commit/2480c1c6b82daaeee0ab82ef45962fbcabd0e778))


### Features

* ideas for plugin wrappers [LIBS-397] ([be38607](https://github.com/dhis2/app-runtime/commit/be38607698b12309af5b79259afbbf037e7027bc))
* implement plugin wrappers (alpha) ([#1332](https://github.com/dhis2/app-runtime/issues/1332)) ([56a9a3f](https://github.com/dhis2/app-runtime/commit/56a9a3fb734e07c6c2d8140c6413222b42be82a1))
* plugin wrappers, errors + alerts ([bda6a43](https://github.com/dhis2/app-runtime/commit/bda6a4352fe0ad8a076f55040e3fe702f9d0c4eb))
* update plugin wrappers ([30c963c](https://github.com/dhis2/app-runtime/commit/30c963c112b2865ae824c7e3ce06279ed374983c))
* **connection-status:** responsiveness to online events [LIBS-497] ([#1348](https://github.com/dhis2/app-runtime/issues/1348)) ([91a3d4d](https://github.com/dhis2/app-runtime/commit/91a3d4d820e6a87b819334bd72709c1de1a777f5))

## [3.9.2](https://github.com/dhis2/app-runtime/compare/v3.9.1...v3.9.2) (2023-05-02)
Expand Down
15 changes: 15 additions & 0 deletions services/plugin/src/Plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export const Plugin = ({

const [communicationReceived, setCommunicationReceived] =
useState<boolean>(false)
const [prevCommunicationReceived, setPrevCommunicationReceived] =
useState<boolean>(false)

const [inErrorState, setInErrorState] = useState<boolean>(false)
const [pluginHeight, setPluginHeight] = useState<number>(150)
Expand All @@ -71,6 +73,17 @@ export const Plugin = ({
}, [height, width])

useEffect(() => {
setCommunicationReceived(false)
}, [pluginEntryPoint])

useEffect(() => {
// if communicationReceived switches from false to true, the props have been sent
const prevCommunication = prevCommunicationReceived
setPrevCommunicationReceived(communicationReceived)
if (prevCommunication === false && communicationReceived === true) {
return
}

if (iframeRef?.current) {
const iframeProps = {
...propsToPass,
Expand Down Expand Up @@ -113,6 +126,8 @@ export const Plugin = ({
})
}
}
// prevCommunicationReceived update should not retrigger this hook
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [propsToPass, communicationReceived, inErrorState, alertsAdd])

if (data && !pluginEntryPoint) {
Expand Down

0 comments on commit cea7600

Please sign in to comment.