livechat / chat-widget-adapters

This project contains a set of libraries for adapting LiveChat Chat Widget with certain frontend frameworks
https://developers.livechat.com
MIT License
24 stars 8 forks source link

Reinitialisation scheduling #53

Closed walaszczykm closed 2 years ago

walaszczykm commented 2 years ago

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 calling LiveChatWidget.destroy() while the widget is loading and track the last desired state instead of conditionally destroying it after it is fully loaded.