Skip to content

Commit

Permalink
HistoryView: Don't show the 'loading commit' thing until after 500 ms.
Browse files Browse the repository at this point in the history
This was annoying me a lot, so it's in stable :)

Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl>
  • Loading branch information
pieter committed Sep 17, 2009
1 parent 34394d0 commit 5972bd4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions html/views/history/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var Commit = function(obj) {
this.sha = obj.realSha();
this.parents = obj.parents;
this.subject = obj.subject;
this.notificationID = null;

// TODO:
// this.author_date instant
Expand Down Expand Up @@ -168,11 +169,12 @@ var loadCommit = function(commitObject, currentRef) {
// Which will be called from the controller once
// the commit details are in.

if (commit && commit.notificationID)
clearTimeout(commit.notificationID);

commit = new Commit(commitObject);
commit.currentRef = currentRef;

notify("Loading commit…", 0);

$("commitID").innerHTML = commit.sha;
$("authorID").innerHTML = commit.author_name;
$("subjectID").innerHTML = commit.subject.escapeHTML();
Expand Down Expand Up @@ -202,6 +204,13 @@ var loadCommit = function(commitObject, currentRef) {
"<a href='' onclick='selectCommit(this.innerHTML); return false;'>" +
commit.parents[i] + "</a></td>";
}

commit.notificationID = setTimeout(function() {
if (!commit.fullyLoaded)
notify("Loading commit…", 0);
commit.notificationID = null;
}, 500);

}

var showDiff = function() {
Expand Down Expand Up @@ -282,6 +291,11 @@ var loadCommitDetails = function(data)
{
commit.parseDetails(data);

if (commit.notificationID)
clearTimeout(commit.notificationID)
else
$("notification").style.display = "none";

var formatEmail = function(name, email) {
return email ? name + " &lt;<a href='mailto:" + email + "'>" + email + "</a>&gt;" : name;
}
Expand Down

0 comments on commit 5972bd4

Please sign in to comment.