An attempt at some Perf improvements

This commit is contained in:
Robin Ward 2013-07-30 17:27:17 -04:00
parent 4b62e70417
commit a2844ea3c6
5 changed files with 561 additions and 403 deletions

View File

@ -13,13 +13,12 @@ Discourse.PostMenuView = Discourse.View.extend({
shouldRerender: Discourse.View.renderIfChanged(
'post.deleted_at',
'post.flagsAvailable.@each',
'post.url',
'post.bookmarked',
'post.reply_count',
'post.showRepliesBelow',
'post.can_delete',
'post.read',
'post.topic.last_read_post_number',
'bookmarkClass',
'bookmarkTooltip',
'shareUrl',
'post.topic.deleted_at'),
render: function(buffer) {
@ -163,7 +162,7 @@ Discourse.PostMenuView = Discourse.View.extend({
renderShare: function(post, buffer) {
buffer.push("<button title=\"" +
(I18n.t("post.controls.share")) +
"\" data-share-url=\"" + (post.get('shareUrl')) + "\" class='share'><i class=\"icon-link\"></i></button>");
"\" data-share-url=\"" + post.get('shareUrl') + "\" class='share'><i class=\"icon-link\"></i></button>");
},
// Reply button

View File

@ -21,6 +21,10 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
postStream: Em.computed.alias('controller.postStream'),
updateBar: function() {
Em.run.scheduleOnce('afterRender', this, 'updateProgressBar');
}.observes('controller.streamPercentage'),
updateProgressBar: function() {
var $topicProgress = $('#topic-progress');
if (!$topicProgress.length) return;
@ -30,8 +34,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
$topicProgress.find('.bg')
.css("border-right-width", (progressWidth === totalWidth) ? "0px" : "1px")
.width(progressWidth);
}.observes('controller.streamPercentage'),
},
updateTitle: function() {
var title = this.get('topic.title');
@ -79,7 +82,6 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
if (this.present('controller.enteredAt')) {
var topicView = this;
Em.run.schedule('afterRender', function() {
topicView.updateBar();
topicView.updatePosition();
});
}
@ -337,7 +339,6 @@ Discourse.TopicView.reopenClass({
// Scroll to a given post, if in the DOM. Returns whether it was in the DOM or not.
jumpToPost: function(topicId, postNumber, avoidScrollIfPossible) {
Em.run.scheduleOnce('afterRender', function() {
var rows = $('.topic-post.ready');
// Make sure we're looking at the topic we want to scroll to

View File

@ -27,7 +27,7 @@
@property description
**/
description: function() {
var result = "Rendered ";
var result = "";
if (this.get('payload.template')) {
result += "'" + this.get('payload.template') + "' ";
}
@ -61,15 +61,15 @@
@method log
**/
log: function() {
if ((!console) || (!console.groupCollapsed)) { return; }
log: function(type) {
if ((typeof console === 'undefined') || (!console.groupCollapsed)) { return; }
// We don't care about really fast renders
if (this.get('time') < 1) { return; }
console.groupCollapsed(this.get('description'));
console.groupCollapsed(type + ": " + this.get('description'));
this.get('children').forEach(function (c) {
c.log();
c.log(type);
});
console.groupEnd();
}
@ -94,7 +94,7 @@
profileNode.set('end', timestamp);
if (!this.depth) {
profileNode.log();
profileNode.log("Render");
}
}
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff