Skip to content

Bugs? #118

@davidquintard

Description

@davidquintard

Hi there
I dont understand this function.
Param currentUser is unused
Variable users is undeclared : "or (let x in users) {"

let getContacts = currentUser => {
		return new Promise((resolve, reject) => {
			db.collection('users').find({

			}).toArray((err, data) => {
				if (err) {
					reject();
					return console.log(err);
				}
				if (!data || !data[0]) {
					resolve([]);
					return;
				}

				let contacts = data.map(contact => {
					let online = false;

					for (let x in users) {
						if (users[x].id == contact._id) {
							online = true;
							break;
						}
					}
					return {
						id: contact._id + '',
						name: contact.name,
						username: contact.username,
						image: contact.image,
						online: online
					};
				});
				resolve(contacts);

			});
		});
	};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions