From f8450f58a49c39eaa8422dfbf60aea967f8d46bc Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 30 Sep 2022 21:20:26 +0200 Subject: [PATCH] fix(task): make sure users can be assigned via quick add magic via their real name as well See https://kolaente.dev/vikunja/frontend/issues/2196#issuecomment-36206 --- src/stores/tasks.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts index a69b1f59..b192e0a2 100644 --- a/src/stores/tasks.ts +++ b/src/stores/tasks.ts @@ -38,9 +38,11 @@ function findPropertyByValue(object, key, value) { ) } -// Check if the user exists -function validateUsername(users: IUser[], username: IUser['username']) { - return findPropertyByValue(users, 'username', username) +// Check if the user exists in the search results +function validateUser(users: IUser[], username: IUser['username']) { + return findPropertyByValue(users, 'username', username) || + findPropertyByValue(users, 'name', username) || + findPropertyByValue(users, 'email', username) } // Check if the label exists @@ -67,7 +69,7 @@ async function findAssignees(parsedTaskAssignees: string[]) { const userService = new UserService() const assignees = parsedTaskAssignees.map(async a => { const users = await userService.getAll({}, {s: a}) - return validateUsername(users, a) + return validateUser(users, a) }) const validatedUsers = await Promise.all(assignees)