Slackbot
09/14/2021, 1:58 PMKam Leung
Ken Kunz
09/14/2021, 2:05 PMcustomer params on window.Papercups.config after the widget has been initialized, will those changes be picked up?user
09/14/2021, 2:05 PMKam Leung
Ken Kunz
09/14/2021, 2:09 PMKen Kunz
09/14/2021, 2:11 PMuser
09/14/2021, 2:15 PMKen Kunz
09/14/2021, 2:20 PMKam Leung
Ken Kunz
09/14/2021, 2:49 PM<script> tag from within a svelte layout component. I have two separate layouts based on whether the user is authenticated or not. If someone logs in or out, the svelte router un-mounts / re-mounts the appropriate layout…Ken Kunz
09/14/2021, 2:49 PM<div id="PapercupsChatWidget"> elements.Ken Kunz
09/14/2021, 2:51 PMonDestroy (un-mount / cleanup phase) of my layout? (in order to prevent memory leaks and/or strange behavior arising from multiple papercups widgets?)user
09/14/2021, 2:52 PMKen Kunz
09/14/2021, 2:55 PM<script> if it hasn’t previously been loaded.Ken Kunz
09/14/2021, 2:57 PMKen Kunz
09/14/2021, 2:58 PMalex
Papercups.identify(customer) ) but for now you might need to hack around it a bit 😕Ken Kunz
09/14/2021, 3:11 PMKen Kunz
09/14/2021, 4:27 PMwindow.Papercups.config after the global <script> widget initialization would still be picked up – e.g., as a way to set customer details after login. From my testing so far, this doesn’t seem to be the case. Can you confirm?alex
Ken Kunz
09/14/2021, 4:34 PMKen Kunz
09/14/2021, 4:35 PMKen Kunz
09/14/2021, 4:36 PMwindow.Papercups.config before the global script is added)…Ken Kunz
09/14/2021, 4:39 PMonDestroy cleanup, I could destroy the PapercupsChatWidget element… then in my layout that’s used for authenticated context, re-inject the global script. Is removing the PapercupsChatWidget element sufficient “cleanup” to avoid issues associated with loading the global script multiple times? Some other recommendation?Ken Kunz
09/14/2021, 4:47 PMvue-papercups repo for some inspiration here – I see in destroyWidget.js that it destroys both the chat widget and the previously injected <script> tag, which makes sense. I will try to follow that approach (unless you have another suggestion).alex
Ken Kunz
09/14/2021, 5:27 PMKen Kunz
09/14/2021, 5:31 PM<script> element and the chat widget element is not adequate cleanup – there must be some residual event listeners registered outside of the PapercupsChatWidget element which I don’t have any way to un-register – so I see console errors when I send a reply from the admin UI.Ken Kunz
09/14/2021, 5:34 PMKen Kunz
09/14/2021, 5:37 PMKen Kunz
09/14/2021, 5:38 PMalex
identify method that you can just invoke whenever you want to switch between anon/identified users might solve things?Ken Kunz
09/14/2021, 6:39 PMalex
alex