Skip to content

Commit 4f3b196

Browse files
committed
comments: Don't load more while loading and update menu on login.
1 parent 1cb310a commit 4f3b196

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/app/releases/details/release.comment.ctrl.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default class ReleaseCommentCtrl {
2626
* @param {CommentResource} CommentResource
2727
* @ngInject
2828
*/
29-
constructor(AuthService, ApiHelper, CommentResource) {
29+
constructor($scope, AuthService, ApiHelper, CommentResource) {
3030
this.AuthService = AuthService;
3131
this.ApiHelper = ApiHelper;
3232
this.CommentResource = CommentResource;
@@ -37,9 +37,11 @@ export default class ReleaseCommentCtrl {
3737
this.editing = false;
3838
this.menuMoveTo = '';
3939
this.onMoved = () => {};
40+
41+
$scope.$watch(() => this.AuthService.user, () => this._updateMenus());
4042
}
4143

42-
$onInit() {
44+
_updateMenus() {
4345
const isOwner = this.AuthService.user && this.AuthService.user.id === this.comment.from.id;
4446
this.hasMoveToMenu = this.menuMoveTo && this.AuthService.hasPermission('releases/moderate');
4547
this.hasEditMenu = isOwner || this.AuthService.hasPermission('releases/moderate');

src/app/releases/details/release.details.ctrl.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,16 @@ export default class ReleaseDetailsCtrl {
240240
}
241241

242242
loadMoreComments() {
243+
if (this.commentsLoading) {
244+
return;
245+
}
246+
this.commentsLoading = true;
243247
this.ReleaseCommentResource.query({
244248
releaseId: this.release.id,
245249
per_page: this.commentsPagesize,
246250
page: ++this.fetchedCommentPages
247251
}, res => {
252+
this.commentsLoading = false;
248253
this._addCommentsToHead(res.data);
249254
});
250255
}

src/app/releases/details/release.details.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ include ../../template/_mixins
240240
.zigzag(ng-show="vm.hiddenComments > 0")
241241
.panel.panel--inner
242242
| {{ vm.hiddenComments }} hidden comments
243-
label.a(ng-click="vm.loadMoreComments()") Load more...
243+
label.a(ng-click="vm.loadMoreComments()") {{ vm.commentsLoading ? 'Loading...' : 'Load more...' }}
244244
release-comment(ng-repeat="comment in vm.commentsTail track by comment.id",
245245
comment="comment",
246246
release="vm.release",

0 commit comments

Comments
 (0)