Last active
July 11, 2019 09:00
-
-
Save pasikonik/adeb556b6a9061b23afb49da7bff1424 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function detectTaskAnProject({ getters, dispatch }) { | |
let projects = getters['project/projects']; | |
if (!projects.length) { | |
projects = await dispatch('project/fetch'); | |
} | |
const tab = await getTabInfo(); | |
const system = await detectSystem(projects, tab); | |
const project = await detectProject(projects, system.id); | |
let task = {}; | |
try { | |
task = system.id ? await detectTask(system, tab) : { ticketUrl: tab.url }; | |
} catch (e) { | |
return { project: { id: project.id } }; | |
} | |
return dispatch('task/add', { | |
project: { id: project.id }, | |
projectSystemId: system.id, | |
externalId: task.ticketId, | |
externalUrl: task.ticketUrl, | |
description: task.ticketDescription, | |
title: (task.ticketTitle && system.id ? task.ticketTitle : tab.content.title), | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment