LucasBassetti / react-simple-chatbot

:speech_balloon: Easy way to create conversation chats
https://lucasbassetti.com.br/react-simple-chatbot/
MIT License
1.71k stars 596 forks source link

get item from localStorage only when the cache is enabled #351

Open LouaiTrabulsi opened 1 year ago

LouaiTrabulsi commented 1 year ago

I need to use the chatbot in an environment that doesn't support localStorage. I saw you are using localStorage for caching purpose, for my case I don't need cache so I leave it as default (disabled), but I realized that in file 'storage.js' you are accessing the localStorage before checking if the cache is enabled: const unParsedCache = localStorage.getItem(cacheName); so I just moved this line to be after checking if cache is enbled:

if (cache) {
    const unParsedCache = localStorage.getItem(cacheName);
    if (unParsedCache) {

this way I will not get an error related to localStorage in my environment. Thanks in advance