Commit 8b6ce17c authored by Ivanq's avatar Ivanq

Add 'Follow' button to issues and pull requests list

parent a39149e5
......@@ -70,6 +70,7 @@
<div class="info">
<a class="button button-blue" id="new_issue">New issue</a>
<a class="button info-link" id="follow"></a>
</div>
<table id="issues" class="issues"></table>
......
......@@ -4,6 +4,10 @@ if(address == "1RepoXU8bQE9m7ssNwL4nnxBnZVejHCc6") {
let currentPage = Number.isSafeInteger(+additional) ? +additional : 0;
function showFollowing(isFollowing) {
document.getElementById("follow").innerHTML = isFollowing ? "Stop following" : "Follow issues and pull requests in newsfeed";
}
repo.addMerger()
.then(() => {
return repo.getContent();
......@@ -69,4 +73,25 @@ repo.addMerger()
button.classList.remove("button-disabled");
button.href = "?" + address + "/" + (currentPage + 1);
}
return repo.isFollowing();
})
.then(isFollowing => {
let followButton = document.getElementById("follow");
showFollowing(isFollowing);
followButton.onclick = () => {
if(isFollowing) {
repo.unfollow()
.then(() => {
isFollowing = false;
showFollowing(isFollowing);
});
} else {
repo.follow()
.then(() => {
isFollowing = true;
showFollowing(isFollowing);
});
}
};
});
\ No newline at end of file
......@@ -70,6 +70,7 @@
<div class="info">
<a class="button button-blue" id="new_pull_request">New pull request</a>
<a class="button info-link" id="follow"></a>
</div>
<table id="pull_requests" class="pull-requests"></table>
......
......@@ -4,6 +4,10 @@ if(address == "1RepoXU8bQE9m7ssNwL4nnxBnZVejHCc6") {
let currentPage = Number.isSafeInteger(+additional) ? +additional : 0;
function showFollowing(isFollowing) {
document.getElementById("follow").innerHTML = isFollowing ? "Stop following" : "Follow issues and pull requests in newsfeed";
}
repo.addMerger()
.then(() => {
return repo.getContent();
......@@ -69,4 +73,25 @@ repo.addMerger()
button.classList.remove("button-disabled");
button.href = "?" + address + "/" + (currentPage + 1);
}
return repo.isFollowing();
})
.then(isFollowing => {
let followButton = document.getElementById("follow");
showFollowing(isFollowing);
followButton.onclick = () => {
if(isFollowing) {
repo.unfollow()
.then(() => {
isFollowing = false;
showFollowing(isFollowing);
});
} else {
repo.follow()
.then(() => {
isFollowing = true;
showFollowing(isFollowing);
});
}
};
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment