Skip to content

Commit

Permalink
Remove SP and task token from task desc in Toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Eismann committed Mar 30, 2022
1 parent b53f2a6 commit 8db2e83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ browser.runtime.onMessage.addListener(async (msg) => {
async function track(cardId) {
const task = await addTask(cardId);
const card = await trektor.trelloGateway.getCard(cardId);
const response = await trektor.togglGateway.startTimeEntry(task.id, card.name);
const cardName = stripStoryPointsAndTaskToken(card.name);
const response = await trektor.togglGateway.startTimeEntry(task.id, cardName);
return response.data;
}

Expand Down Expand Up @@ -66,3 +67,9 @@ async function addTask(cardId) {
const response = await trektor.togglGateway.createTask(projects[0].id, taskName)
return response.data;
}

function stripStoryPointsAndTaskToken(cardName) {
return cardName
.replace(/^(\s*\(\d+\))?\s*/, '') // story points, e.g. (3)
.replace(/\s*#[a-z0-9_]+\s*$/, ''); // task token, e.g. #orga_5417
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Trektor",
"description": "Browser-Extension zum automatischen Anlegen von Toggl tracking tasks",
"version": "0.0.10",
"version": "0.0.11",
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
Expand Down

0 comments on commit 8db2e83

Please sign in to comment.