(chatflowid, chatId, saveObj = {})
| 881 | } |
| 882 | |
| 883 | export const setLocalStorageChatflow = (chatflowid, chatId, saveObj = {}) => { |
| 884 | const chatDetails = localStorage.getItem(`${chatflowid}_INTERNAL`) |
| 885 | const obj = { ...saveObj } |
| 886 | if (chatId) obj.chatId = chatId |
| 887 | |
| 888 | if (!chatDetails) { |
| 889 | localStorage.setItem(`${chatflowid}_INTERNAL`, JSON.stringify(obj)) |
| 890 | } else { |
| 891 | try { |
| 892 | const parsedChatDetails = JSON.parse(chatDetails) |
| 893 | localStorage.setItem(`${chatflowid}_INTERNAL`, JSON.stringify({ ...parsedChatDetails, ...obj })) |
| 894 | } catch (e) { |
| 895 | const chatId = chatDetails |
| 896 | obj.chatId = chatId |
| 897 | localStorage.setItem(`${chatflowid}_INTERNAL`, JSON.stringify(obj)) |
| 898 | } |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | export const getLocalStorageChatflow = (chatflowid) => { |
| 903 | const chatDetails = localStorage.getItem(`${chatflowid}_INTERNAL`) |
no test coverage detected