After investigating the original issue, it looks like the Widget cannot be properly destroyed during its initialization process as it might lead to unexpected errors. If the Widget starts loading, we need to wait until it is loaded before making a decision if it should be destroyed or not.
This PR implements reinitialization scheduling which relies on LC_API.on_after_load for synchronous abut widget being initialized. Prevent from calling LiveChatWidget.destroy() while the widget is loading and track the last desired state instead of conditionally destroying it after it is fully loaded.
Type of change
Packages
Issue
https://github.com/livechat/chat-widget-adapters/issues/51
Description
After investigating the original issue, it looks like the Widget cannot be properly destroyed during its initialization process as it might lead to unexpected errors. If the Widget starts loading, we need to wait until it is loaded before making a decision if it should be destroyed or not.
This PR implements reinitialization scheduling which relies on
LC_API.on_after_load
for synchronous abut widget being initialized. Prevent from callingLiveChatWidget.destroy()
while the widget is loading and track the last desired state instead of conditionally destroying it after it is fully loaded.