Skip to content

Commit

Permalink
fix(github): Add issue number to a timer entry in a GitHub project (#…
Browse files Browse the repository at this point in the history
…2287)

Closes #2116
  • Loading branch information
pkvach authored Sep 23, 2024
1 parent 1c11be0 commit b2c4cfc
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/content/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,28 @@ togglbutton.render(
".js-project-card-details .js-comment:not(.toggl)",
{ observe: true },
function (elem) {
const titleElem = $(".js-issue-title");
const numElem = $(
".js-project-card-details .project-comment-title-hover span.color-text-tertiary"
);
const projectElem = $("h1.public strong a, h1.private strong a");
const getDescription = () => {
const titleElem = $(".js-issue-title");

let description = titleElem.textContent;
if (numElem !== null) {
description = numElem.textContent + " " + description.trim();
}
if (!titleElem) {
return "";
}
const issueNumberElem = $(".js-issue-title + span");
const issueTitle = titleElem.textContent.trim();

// Check if the text starts with a '#' followed by digits, indicating an issue number
if (issueNumberElem && /^#\d+/.test(issueNumberElem.textContent)) {
return issueNumberElem.textContent.trim() + " " + issueTitle;
}

return issueTitle;
};

const projectElem = $("h1.public strong a, h1.private strong a");

const link = togglbutton.createTimerLink({
className: "github",
description: description,
description: getDescription,
projectName: projectElem && projectElem.textContent,
});

Expand Down

0 comments on commit b2c4cfc

Please sign in to comment.