added comment

This commit is contained in:
Michael Shanks 2020-09-29 15:35:51 +01:00
parent 69292c353c
commit f2a7ec83d7
1 changed files with 3 additions and 1 deletions

View File

@ -28,8 +28,10 @@
const validateApiKey = async apiKey => { const validateApiKey = async apiKey => {
if (!apiKey) return false if (!apiKey) return false
// make sure we only fetch once // make sure we only fetch once, unless API Key is changed
if (isApiKeyValid === undefined || apiKey !== lastApiKey) { if (isApiKeyValid === undefined || apiKey !== lastApiKey) {
// svelte reactivity was causing a requst to get fired mutiple times
// so, we make everything await the same promise, if one exists
if (!fetchApiKeyPromise) { if (!fetchApiKeyPromise) {
fetchApiKeyPromise = analytics.identifyByApiKey(apiKey) fetchApiKeyPromise = analytics.identifyByApiKey(apiKey)
} }