Unverified Commit 70954786 authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Dennis Schubert
Browse files

Refactor SPV post interactions

closes #7089
parent 0e5141dd
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,7 @@ Note: Although this is a minor release, the configuration file changed because t
* Load jQuery in the head on mobile [#7086](https://github.com/diaspora/diaspora/pull/7086)
* Load jQuery in the head on mobile [#7086](https://github.com/diaspora/diaspora/pull/7086)
* Use translation for NodeInfo services [#7102](https://github.com/diaspora/diaspora/pull/7102)
* Use translation for NodeInfo services [#7102](https://github.com/diaspora/diaspora/pull/7102)
* Adopt new Mapbox tile URIs [#7066](https://github.com/diaspora/diaspora/pull/7066)
* Adopt new Mapbox tile URIs [#7066](https://github.com/diaspora/diaspora/pull/7066)
* Refactored post interactions on the single post view [#7089](https://github.com/diaspora/diaspora/pull/7089)


## Bug fixes
## Bug fixes
* Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
* Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
+3 −4
Original line number Original line Diff line number Diff line
@@ -13,9 +13,8 @@ app.views.CommentStream = app.views.Base.extend({
    "click .toggle_post_comments": "expandComments"
    "click .toggle_post_comments": "expandComments"
  },
  },


  initialize: function(options) {
  initialize: function() {
    this.commentTemplate = options.commentTemplate;
    this.CommentView = app.views.Comment;

    this.setupBindings();
    this.setupBindings();
  },
  },


@@ -84,7 +83,7 @@ app.views.CommentStream = app.views.Base.extend({
    // on post ownership in the Comment view.
    // on post ownership in the Comment view.
    comment.set({parent : this.model.toJSON()});
    comment.set({parent : this.model.toJSON()});


    var commentHtml = new app.views.Comment({model: comment}).render().el;
    var commentHtml = new this.CommentView({model: comment}).render().el;
    var commentBlocks = this.$(".comments div.comment.media");
    var commentBlocks = this.$(".comments div.comment.media");
    this._moveInsertPoint(comment.get("created_at"), commentBlocks);
    this._moveInsertPoint(comment.get("created_at"), commentBlocks);
    if (this._insertPoint >= commentBlocks.length) {
    if (this._insertPoint >= commentBlocks.length) {
+3 −10
Original line number Original line Diff line number Diff line
@@ -4,7 +4,10 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
  tooltipSelector: "time, .control-icons a",
  tooltipSelector: "time, .control-icons a",


  initialize: function(){
  initialize: function(){
    this.CommentView = app.views.ExpandedComment;
    $(window).on('hashchange',this.highlightPermalinkComment);
    $(window).on('hashchange',this.highlightPermalinkComment);
    this.setupBindings();
    this.model.comments.on("reset", this.render, this);
  },
  },


  highlightPermalinkComment: function() {
  highlightPermalinkComment: function() {
@@ -24,16 +27,6 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
    _.defer(this.highlightPermalinkComment);
    _.defer(this.highlightPermalinkComment);
  },
  },


  appendComment: function(comment) {
    // Set the post as the comment's parent, so we can check
    // on post ownership in the Comment view.
    comment.set({parent : this.model.toJSON()});

    this.$(".comments").append(new app.views.ExpandedComment({
      model: comment
    }).render().el);
  },

  presenter: function(){
  presenter: function(){
    return _.extend(this.defaultPresenter(), {
    return _.extend(this.defaultPresenter(), {
      moreCommentsCount : 0,
      moreCommentsCount : 0,
+22 −0
Original line number Original line Diff line number Diff line
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later

app.views.SinglePostInteractionCounts = app.views.Base.extend({
  templateName: "single-post-viewer/single-post-interaction-counts",
  tooltipSelector: ".avatar.micro",

  initialize: function() {
    this.model.interactions.on("change", this.render, this);
  },

  presenter: function() {
    var interactions = this.model.interactions;
    return {
      likes: interactions.likes.toJSON(),
      reshares: interactions.reshares.toJSON(),
      commentsCount: interactions.commentsCount(),
      likesCount: interactions.likesCount(),
      resharesCount: interactions.resharesCount()
    };
  }
});
// @license-end
+7 −16
Original line number Original line Diff line number Diff line
@@ -2,28 +2,19 @@


app.views.SinglePostInteractions = app.views.Base.extend({
app.views.SinglePostInteractions = app.views.Base.extend({
  templateName: "single-post-viewer/single-post-interactions",
  templateName: "single-post-viewer/single-post-interactions",
  tooltipSelector: ".avatar.micro",
  className: "framed-content",
  className: "framed-content",


  subviews: {
  subviews: {
    '#comments': 'commentStreamView'
    "#comments": "commentStreamView",
    "#interaction-counts": "interactionCountsView"
  },
  },


  initialize : function() {
  commentStreamView: function() {
    this.model.interactions.on('change', this.render, this);
    return new app.views.SinglePostCommentStream({model: this.model});
    this.commentStreamView = new app.views.SinglePostCommentStream({model: this.model});
  },
  },


  presenter : function(){
  interactionCountsView: function() {
    var interactions = this.model.interactions;
    return new app.views.SinglePostInteractionCounts({model: this.model});
    return {
  }
      likes : interactions.likes.toJSON(),
      comments : interactions.comments.toJSON(),
      reshares : interactions.reshares.toJSON(),
      commentsCount : interactions.commentsCount(),
      likesCount : interactions.likesCount(),
      resharesCount : interactions.resharesCount(),
    };
  },
});
});
// @license-end
// @license-end
Loading