diff --git a/src/plugins/sib-subscribe-to-rai.js b/src/plugins/sib-subscribe-to-rai.js index 60da2ed118375d5872a48394fe4e0b52d8078063..ec288cc860d7da529c5fb7477eb0f731345c97c3 100644 --- a/src/plugins/sib-subscribe-to-rai.js +++ b/src/plugins/sib-subscribe-to-rai.js @@ -39,16 +39,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 3eaa77f2e0fd11ed2a6b124ee42408d17aa617c9..6ddcb7a548d0473860a86803fba2f9711af8562e 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);