Skip to content
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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gustavosbarreto
Copy link

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
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.

1 participant