diff --git a/src/plugins/sib-subscribe-to-rai.js b/src/plugins/sib-subscribe-to-rai.js index 7d08242bf4d02947a7d1d3637b436098d5b815bb..d0e1905cc83d6ba746925566cc3838f4217cb665 100644 --- a/src/plugins/sib-subscribe-to-rai.js +++ b/src/plugins/sib-subscribe-to-rai.js @@ -40,16 +40,18 @@ converse.plugins.add('sib-subscribe-to-rai', { let projects = []; const user = await document.querySelector('sib-auth').getUser(); const userProfile = await store.getData(user['@id'], this.context); - for (let projectMembership of await userProfile['projects.ldp:contains']) { - if (projectMembership) { - projects.push(await projectMembership['project.jabberID']); - } else { - retry = true; + if (userProfile && await userProfile['projects.ldp:contains'] && await userProfile['projects.ldp:contains'] !== 'undefined') { + for (let projectMembership of await userProfile['projects.ldp:contains']) { + if (projectMembership) { + projects.push(await projectMembership['project.jabberID']); + } else { + retry = true; + } + } + if (!retry) { + clearInterval(projectInterval); + resolve(projects); } - } - if (!retry) { - clearInterval(projectInterval); - resolve(projects); } }, 250); }); diff --git a/src/solid-xmpp-chat.js b/src/solid-xmpp-chat.js index 5ca7bd183dce12539286967a99e78fd4a3f734d5..ba8f684dc660327559ee5721856e1e87e25d808e 100644 --- a/src/solid-xmpp-chat.js +++ b/src/solid-xmpp-chat.js @@ -92,20 +92,22 @@ import('./utils.js').then(utils => { const contactInterval = setInterval(async () => { let retry = false; let userContacts = []; - for (let contact of await userProfile['contacts.ldp:contains']) { - if (contact) { - userContacts.push(await contact['contact.@id']); - } else { - retry = true; + if (userProfile && await userProfile['contacts.ldp:contains'] && await userProfile['contacts.ldp:contains'] !== 'undefined') { + for (let contact of await userProfile['contacts.ldp:contains']) { + if (contact) { + userContacts.push(await contact['contact.@id']); + } else { + retry = true; + } } - } - if (!retry) { - clearInterval(contactInterval); - if (!userContacts.includes(this.resource['@id'])) { - core.store.post({ - 'contact': this.resource['@id'], - '@context': this.context, - }, contactsURL); + if (!retry) { + clearInterval(contactInterval); + if (!userContacts.includes(this.resource['@id'])) { + core.store.post({ + 'contact': this.resource['@id'], + '@context': this.context, + }, contactsURL); + } } } }, 100);