Unverified Commit 4fea9260 authored by Benjamin Neff's avatar Benjamin Neff Committed by Dennis Schubert
Browse files

Only update interacted_at on new comments

I got feedback from many users, that they don't understand how the "my
activity" stream is sorted, because they have posts on the top, but
don't see why. The user doesn't see if a like was added, and it is also
not imported for the user to see the post again then. And we have
notifications if someone likes a users own posts, so no need to move it on
top of the "my activity" stream here too.

closes #7030
parent 02ad431f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
* Remove text color from notification mails and fix sender avatar [#7054](https://github.com/diaspora/diaspora/pull/7054)
* Make the session cookies HttpOnly again [#7041](https://github.com/diaspora/diaspora/pull/7041)
* Invalidate sessions with invalid CSRF tokens [#7050](https://github.com/diaspora/diaspora/pull/7050)
* Liking a post will no longer update its interacted timestamp [#7030](https://github.com/diaspora/diaspora/pull/7030)

## Bug fixes
* Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
+3 −2
Original line number Diff line number Diff line
@@ -38,8 +38,9 @@ class Comment < ActiveRecord::Base
    self.text.strip! unless self.text.nil?
  end

  after_commit :on => :create do
    self.parent.update_comments_counter
  after_commit on: :create do
    parent.update_comments_counter
    parent.touch(:interacted_at) if parent.respond_to?(:interacted_at)
  end

  after_destroy do
+0 −4
Original line number Diff line number Diff line
@@ -11,10 +11,6 @@ module Diaspora

        delegate :public?, to: :parent
        delegate :author, :diaspora_handle, to: :parent, prefix: true

        after_commit :on => :create do
          parent.touch(:interacted_at) if parent.respond_to?(:interacted_at)
        end
      end
    end

+2 −2
Original line number Diff line number Diff line
@@ -83,8 +83,8 @@ describe EvilQuery::Participation do
      expect(posts.map(&:id)).to match_array([@status_messageA.id, @status_messageB.id, @status_messageE.id])
    end

    it "returns the posts that the user has commented on or liked with the most recently acted on ones first" do
      expect(posts.map(&:id)).to eq([@status_messageE.id, @status_messageA.id, @status_messageB.id])
    it "returns the posts that the user has commented on most recently first" do
      expect(posts.map(&:id)).to eq([@status_messageE.id, @status_messageB.id, @status_messageA.id])
    end
  end

+10 −0
Original line number Diff line number Diff line
@@ -66,6 +66,16 @@ describe Comment, type: :model do
    end
  end

  describe "interacted_at" do
    it "sets the interacted at of the parent to the created at of the comment" do
      Timecop.travel(Time.zone.now + 1.minute)

      comment = Comment::Generator.new(alice, status_bob, "why so formal?").build
      comment.save
      expect(status_bob.reload.interacted_at.to_i).to eq(comment.created_at.to_i)
    end
  end

  it_behaves_like "it is relayable" do
    let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) }
    let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) }
Loading