FIX: reply as new link wasn't working sometimes

This commit is contained in:
Régis Hanol 2016-06-20 12:09:04 +02:00
parent 5e2545a578
commit 9c5a727aa2
3 changed files with 8 additions and 6 deletions

View file

@ -26,15 +26,14 @@ export default Ember.Controller.extend({
// Close the share controller // Close the share controller
actions: { actions: {
close() { close() {
this.setProperties({ link: '', postNumber: '' }); this.setProperties({ link: null, postNumber: null, postId: null });
return false; return false;
}, },
replyAsNewTopic() { replyAsNewTopic() {
const topicController = this.get("controllers.topic"); const topicController = this.get("controllers.topic");
const postStream = topicController.get("model.postStream"); const postStream = topicController.get("model.postStream");
const postId = postStream.findPostIdForPostNumber(this.get("postNumber")); const post = postStream.findLoadedPost(this.get("postId"));
const post = postStream.findLoadedPost(postId);
topicController.send("replyAsNewTopic", post); topicController.send("replyAsNewTopic", post);
this.send("close"); this.send("close");
}, },

View file

@ -47,7 +47,7 @@ export default Ember.View.extend({
return true; return true;
}); });
function showPanel($target, url, postNumber, date) { function showPanel($target, url, postNumber, date, postId) {
const $currentTargetOffset = $target.offset(); const $currentTargetOffset = $target.offset();
const $shareLink = $('#share-link'); const $shareLink = $('#share-link');
@ -77,6 +77,7 @@ export default Ember.View.extend({
self.set('controller.link', url); self.set('controller.link', url);
self.set('controller.postNumber', postNumber); self.set('controller.postNumber', postNumber);
self.set('controller.postId', postId);
self.set('controller.date', date); self.set('controller.date', date);
} }
@ -91,8 +92,9 @@ export default Ember.View.extend({
const $currentTarget = $(e.currentTarget), const $currentTarget = $(e.currentTarget),
url = $currentTarget.data('share-url'), url = $currentTarget.data('share-url'),
postNumber = $currentTarget.data('post-number'), postNumber = $currentTarget.data('post-number'),
postId = $currentTarget.data('post-id'),
date = $currentTarget.children().data('time'); date = $currentTarget.children().data('time');
showPanel($currentTarget, url, postNumber, date); showPanel($currentTarget, url, postNumber, date, postId);
return false; return false;
}); });

View file

@ -161,7 +161,8 @@ createWidget('post-meta-data', {
attributes: { attributes: {
href: attrs.shareUrl, href: attrs.shareUrl,
'data-share-url': attrs.shareUrl, 'data-share-url': attrs.shareUrl,
'data-post-number': attrs.post_number 'data-post-number': attrs.post_number,
'data-post-id': attrs.id,
} }
}, dateNode(createdAt)) }, dateNode(createdAt))
)); ));