mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Progress was broken on mobile
This commit is contained in:
parent
a8251b3036
commit
fc4dc76f42
@ -171,7 +171,7 @@ export default Ember.Component.extend({
|
|||||||
}
|
}
|
||||||
this.set('toPostIndex', postIndex);
|
this.set('toPostIndex', postIndex);
|
||||||
this.set('expanded', false);
|
this.set('expanded', false);
|
||||||
this.sendAction('jumpToPost', postIndex);
|
this.sendAction('jumpToIndex', postIndex);
|
||||||
},
|
},
|
||||||
|
|
||||||
jumpTop() {
|
jumpTop() {
|
||||||
|
@ -191,9 +191,13 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||||||
if (!post) { return; }
|
if (!post) { return; }
|
||||||
|
|
||||||
const postNumber = post.get('post_number');
|
const postNumber = post.get('post_number');
|
||||||
this.set('model.currentPost', postNumber);
|
const model = this.get('model');
|
||||||
|
model.set('currentPost', postNumber);
|
||||||
this.send('postChangedRoute', postNumber);
|
this.send('postChangedRoute', postNumber);
|
||||||
this.appEvents.trigger('topic:current-post-changed', postNumber);
|
|
||||||
|
const postStream = model.get('postStream');
|
||||||
|
|
||||||
|
this.appEvents.trigger('topic:current-post-changed', postStream.progressIndexOfPost(post));
|
||||||
},
|
},
|
||||||
|
|
||||||
// Called the the topmost visible post on the page changes.
|
// Called the the topmost visible post on the page changes.
|
||||||
@ -391,25 +395,12 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
jumpToIndex(index) {
|
||||||
|
this._jumpToPostId(this.get('model.postStream.stream')[index-1]);
|
||||||
|
},
|
||||||
|
|
||||||
jumpToPost(postNumber) {
|
jumpToPost(postNumber) {
|
||||||
const topic = this.get('model');
|
this._jumpToPostId(this.get('model.postStream').findPostIdForPostNumber(postNumber));
|
||||||
const stream = topic.get('postStream');
|
|
||||||
const postId = stream.findPostIdForPostNumber(postNumber);
|
|
||||||
|
|
||||||
if (!postId) {
|
|
||||||
Em.Logger.warn("jump-post code broken - requested an index outside the stream array");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const post = stream.findLoadedPost(postId);
|
|
||||||
if (post) {
|
|
||||||
DiscourseURL.routeTo(topic.urlForPostNumber(post.get('post_number')));
|
|
||||||
} else {
|
|
||||||
// need to load it
|
|
||||||
stream.findPostsByIds([postId]).then(arr => {
|
|
||||||
DiscourseURL.routeTo(topic.urlForPostNumber(arr[0].get('post_number')));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
jumpTop() {
|
jumpTop() {
|
||||||
@ -647,6 +638,25 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_jumpToPostId(postId) {
|
||||||
|
if (!postId) {
|
||||||
|
Ember.Logger.warn("jump-post code broken - requested an index outside the stream array");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const topic = this.get('model');
|
||||||
|
const postStream = topic.get('postStream');
|
||||||
|
const post = postStream.findLoadedPost(postId);
|
||||||
|
if (post) {
|
||||||
|
DiscourseURL.routeTo(topic.urlForPostNumber(post.get('post_number')));
|
||||||
|
} else {
|
||||||
|
// need to load it
|
||||||
|
postStream.findPostsByIds([postId]).then(arr => {
|
||||||
|
DiscourseURL.routeTo(topic.urlForPostNumber(arr[0].get('post_number')));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
togglePinnedState() {
|
togglePinnedState() {
|
||||||
this.send('togglePinnedForUser');
|
this.send('togglePinnedForUser');
|
||||||
},
|
},
|
||||||
|
@ -76,12 +76,14 @@
|
|||||||
loading=model.postStream.loading
|
loading=model.postStream.loading
|
||||||
jumpTop="jumpTop"
|
jumpTop="jumpTop"
|
||||||
jumpToPost="jumpToPost"
|
jumpToPost="jumpToPost"
|
||||||
|
jumpToIndex="jumpToIndex"
|
||||||
jumpBottom="jumpBottom"
|
jumpBottom="jumpBottom"
|
||||||
replyToPost="replyToPost"}}
|
replyToPost="replyToPost"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{topic-progress topic=model
|
{{topic-progress topic=model
|
||||||
jumpTop="jumpTop"
|
jumpTop="jumpTop"
|
||||||
jumpToPost="jumpToPost"
|
jumpToPost="jumpToPost"
|
||||||
|
jumpToIndex="jumpToIndex"
|
||||||
jumpBottom="jumpBottom"}}
|
jumpBottom="jumpBottom"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{conditional-loading-spinner condition=model.postStream.loadingAbove}}
|
{{conditional-loading-spinner condition=model.postStream.loadingAbove}}
|
||||||
|
@ -90,7 +90,7 @@ createWidget('timeline-scrollarea', {
|
|||||||
const { attrs } = this;
|
const { attrs } = this;
|
||||||
const percentage = this.state.percentage;
|
const percentage = this.state.percentage;
|
||||||
const postStream = attrs.topic.get('postStream');
|
const postStream = attrs.topic.get('postStream');
|
||||||
const total = attrs.topic.get('highest_post_number');
|
const total = postStream.get('filteredPostsCount');
|
||||||
let current = Math.round(total * percentage);
|
let current = Math.round(total * percentage);
|
||||||
|
|
||||||
if (current < 1) { current = 1; }
|
if (current < 1) { current = 1; }
|
||||||
@ -157,13 +157,13 @@ createWidget('timeline-scrollarea', {
|
|||||||
|
|
||||||
commit() {
|
commit() {
|
||||||
const position = this.position();
|
const position = this.position();
|
||||||
this.sendWidgetAction('jumpToPost', position.current);
|
this.sendWidgetAction('jumpToIndex', position.current);
|
||||||
},
|
},
|
||||||
|
|
||||||
topicCurrentPostChanged(postNumber) {
|
topicCurrentPostChanged(postNumber) {
|
||||||
// If the post number didn't change keep our scroll position
|
// If the post number didn't change keep our scroll position
|
||||||
if (postNumber !== this.state.scrolledPost) {
|
if (postNumber !== this.state.scrolledPost) {
|
||||||
const total = this.attrs.topic.get('highest_post_number');
|
const total = this.attrs.topic.get('postStream.filteredPostsCount');
|
||||||
const perc = postNumber === 1 ? 0.0 : parseFloat(postNumber) / total;
|
const perc = postNumber === 1 ? 0.0 : parseFloat(postNumber) / total;
|
||||||
this.state.percentage = perc;
|
this.state.percentage = perc;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user