Skip to content

Commit

Permalink
Remove glitch when leaving. Closes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Feb 1, 2017
1 parent 8e245d7 commit 16b8a57
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,11 @@ scrum.app.controller('MemberController', function MemberController ($http, $loca
this.id = $routeParams.sessionId;
this.member = $routeParams.memberId;
this.votable = false;
this.leaving = false;
this.topic = '';

// Self reference for callbacks
var self = this;

// Reset the member UI
this.reset = function () {
Expand All @@ -374,10 +378,13 @@ scrum.app.controller('MemberController', function MemberController ($http, $loca

// Leave the session
this.leave = function () {
this.leaving = true;
$http.post("/api/session/remove", {
memberId: this.member
}).then(function (response) {
$location.url("/");
}, function() {
self.leaving = false;
});
};

Expand All @@ -400,7 +407,6 @@ scrum.app.controller('MemberController', function MemberController ($http, $loca
};

// Update current topic from server to activate voting
var self = this;
function update() {
if (scrum.current !== self) return;

Expand Down Expand Up @@ -436,12 +442,16 @@ scrum.app.controller('MemberController', function MemberController ($http, $loca
// Check if we are still here
$http.get("/api/session/membercheck?sid=" + self.id + '&mid=' + self.member).then(function(response){
var data = response.data;
if(data.success && !data.result) {
if (self.leaving) {
return;
}

if (data.success && !data.result) {
$location.url("/removal");
}
});
};

// Start timer
// Start timer
update();
});

0 comments on commit 16b8a57

Please sign in to comment.