Skip to content

Commit 6ed6918

Browse files
committed
Load more posts after post deletion
Closes #6390 - check if more posts should be loaded whenever one is deleted - delete dead code from posts controller - delete duplicate component gh-infinite-scroll-box - simplify posts-list-item `posts.post` or `editor.edit` link logic by modifying `gh-content-view-container` to yield necessary vars directly and use inline ifs in template - add `gh-tag` component for rendering tags and updating infinite scroll box on `settings/tags` page
1 parent 0bb2a2f commit 6ed6918

File tree

13 files changed

+44
-71
lines changed

13 files changed

+44
-71
lines changed

core/client/app/components/gh-infinite-scroll-box.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

core/client/app/components/gh-infinite-scroll.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,10 @@ import InfiniteScrollMixin from 'ghost/mixins/infinite-scroll';
33

44
const {Component} = Ember;
55

6-
export default Component.extend(InfiniteScrollMixin);
6+
export default Component.extend(InfiniteScrollMixin, {
7+
actions: {
8+
checkScroll() {
9+
this._checkScroll();
10+
}
11+
}
12+
});

core/client/app/components/gh-posts-list-item.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ export default Component.extend(ActiveLinkWrapper, {
3434
return Ember.String.htmlSafe(`background-image: url(${this.get('authorAvatar')})`);
3535
}),
3636

37-
viewOrEdit: computed('previewIsHidden', function () {
38-
return this.get('previewIsHidden') ? 'editor.edit' : 'posts.post';
39-
}),
40-
4137
click() {
4238
this.sendAction('onClick', this.get('post'));
4339
},
@@ -54,6 +50,9 @@ export default Component.extend(ActiveLinkWrapper, {
5450
willDestroyElement() {
5551
this._super(...arguments);
5652
this.removeObserver('active', this, this.scrollIntoView);
53+
if (this.get('post.isDeleted') && this.attrs.onDelete) {
54+
this.attrs.onDelete();
55+
}
5756
},
5857

5958
scrollIntoView() {

core/client/app/components/gh-tag.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Ember from 'ember';
2+
3+
export default Ember.Component.extend({
4+
willDestroyElement() {
5+
this._super(...arguments);
6+
7+
if (this.get('tag.isDeleted') && this.attrs.onDelete) {
8+
this.attrs.onDelete();
9+
}
10+
}
11+
});

core/client/app/controllers/posts.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,6 @@ export default Controller.extend({
8181
}),
8282

8383
actions: {
84-
showPostContent(post) {
85-
if (!post) {
86-
return;
87-
}
88-
89-
this.transitionToRoute('posts.post', post);
90-
},
91-
9284
toggleDeletePostModal() {
9385
this.toggleProperty('showDeletePostModal');
9486
}

core/client/app/mixins/infinite-scroll.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ export default Mixin.create({
88

99
/**
1010
* Determines if we are past a scroll point where we need to fetch the next page
11-
* @param {object} event The scroll event
1211
*/
13-
checkScroll(event) {
14-
let element = event.target;
12+
_checkScroll() {
13+
let element = this.get('element');
1514
let triggerPoint = this.get('triggerPoint');
1615
let isLoading = this.get('isLoading');
1716

@@ -28,11 +27,11 @@ export default Mixin.create({
2827

2928
let el = this.get('element');
3029

31-
el.onscroll = run.bind(this, this.checkScroll);
30+
el.onscroll = run.bind(this, this._checkScroll);
3231

33-
if (el.scrollHeight <= el.clientHeight) {
34-
this.sendAction('fetch');
35-
}
32+
// run on load, on the offchance that the initial load
33+
// did not fill the view.
34+
this._checkScroll();
3635
},
3736

3837
willDestroyElement() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{yield this}}
1+
{{yield previewIsHidden}}

core/client/app/templates/components/gh-infinite-scroll-box.hbs

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{yield}}
1+
{{yield (action "checkScroll")}}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div class="settings-tag">
2+
{{#link-to 'settings.tags.tag' tag class="tag-edit-button"}}
3+
<span class="tag-title">{{tag.name}}</span>
4+
<span class="label label-default">/{{tag.slug}}</span>
5+
<p class="tag-description">{{tag.description}}</p>
6+
<span class="tags-count">{{tag.count.posts}}</span>
7+
{{/link-to}}
8+
</div>

0 commit comments

Comments
 (0)