Skip to content

refactor: replace time-based polling with Chatwoot builtin event #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

gustavosbarreto
Copy link
Contributor

Description

Replaced the time-based polling mechanism with a Chatwoot builtin event listener for detecting readiness. Introduced isReady and waitForReady utility to ensure Chatwoot API calls are made only after initialization

Additional context

This also fixes an occasional bug where observer.value.observe fails with TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'. The error occurred because document.querySelector('.woot-widget-holder') sometimes returned null, causing startObserver to initialize with an invalid node.

Replaced the time-based polling mechanism with a Chatwoot builtin event
listener for detecting readiness. Introduced `isReady` and `waitForReady`
utility to ensure Chatwoot API calls are made only after initialization

This also fixes an occasional bug where `observer.value.observe` fails
with `TypeError: Failed to execute 'observe' on 'MutationObserver':
parameter 1 is not of type 'Node'`. The error occurred because
`document.querySelector('.woot-widget-holder')` sometimes returned
`null`, causing `startObserver` to initialize with an invalid node.
@gustavosbarreto gustavosbarreto force-pushed the refactor/chatwoot-ready-event branch from fa85a37 to 4291235 Compare February 14, 2025 14:20
@productdevbook productdevbook self-requested a review February 20, 2025 09:20
@productdevbook
Copy link
Contributor

Thank you ❤️

@productdevbook productdevbook merged commit cd012bc into productdevbookcom:main Feb 20, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants