From 267a1df3c46fd4a7fcb1d749d8bbe2d1c582d91f Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Mon, 18 May 2015 00:27:54 +0200 Subject: [PATCH 1/3] fix root_diaspora_id when root was deleted --- app/models/reshare.rb | 2 +- spec/models/reshare_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/reshare.rb b/app/models/reshare.rb index c10cde1f0..93803af1d 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -26,7 +26,7 @@ class Reshare < Post end def root_diaspora_id - self.root.author.diaspora_handle + root.try(:author).try(:diaspora_handle) end delegate :o_embed_cache, :open_graph_cache, diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb index 155ac527d..ff1781b9a 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -20,6 +20,19 @@ describe Reshare, :type => :model do expect(FactoryGirl.create(:reshare, :public => false).public).to be true end + describe "#root_diaspora_id" do + it "should return the root diaspora id" do + reshare = FactoryGirl.create(:reshare, root: FactoryGirl.build(:status_message, author: bob.person, public: true)) + expect(reshare.root_diaspora_id).to eq(bob.person.diaspora_handle) + end + + it "should be nil if no root found" do + reshare = FactoryGirl.create(:reshare, root: FactoryGirl.build(:status_message, author: bob.person, public: true)) + reshare.root = nil + expect(reshare.root_diaspora_id).to be_nil + end + end + describe "#receive" do let(:receive_reshare) { @reshare.receive(@root.author.owner, @reshare.author) } From cde9b24476b3066ac7084b0c7163940b62feff71 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Mon, 18 May 2015 00:29:38 +0200 Subject: [PATCH 2/3] fix margin/padding for "original post deleted"-message --- app/assets/templates/reshare_tpl.jst.hbs | 25 ++++++++---------------- app/views/reshares/_reshare.mobile.haml | 3 ++- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/app/assets/templates/reshare_tpl.jst.hbs b/app/assets/templates/reshare_tpl.jst.hbs index a1a661658..b1334fa0a 100644 --- a/app/assets/templates/reshare_tpl.jst.hbs +++ b/app/assets/templates/reshare_tpl.jst.hbs @@ -1,16 +1,11 @@
- - {{#if root}} - -
- +
+ {{#if root}} {{#with root}} {{{personImage author 'small'}}} - {{/with}} - {{#with root}}
{{#linkToAuthor author}} @@ -33,14 +28,10 @@ {{> status-message}}
- -
- - {{else}} - -

- {{t "stream.original_post_deleted"}} -

- {{/if}} - + {{else}} +

+ {{t "stream.original_post_deleted"}} +

+ {{/if}} +
diff --git a/app/views/reshares/_reshare.mobile.haml b/app/views/reshares/_reshare.mobile.haml index 6d8a11549..36ee8c2e6 100644 --- a/app/views/reshares/_reshare.mobile.haml +++ b/app/views/reshares/_reshare.mobile.haml @@ -12,7 +12,8 @@ - if !post.activity_streams? = render 'status_messages/status_message', :post => post, :photos => post.photos - else - = t('.deleted') + .content + = t('.deleted') .reshare_via %span From 289753e068bd351f1916d4ca280ed68cba38ad2e Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Mon, 18 May 2015 01:59:24 +0200 Subject: [PATCH 3/3] add "original post deleted" message on single post view closes #5968 --- Changelog.md | 1 + app/assets/javascripts/app/views/content_view.js | 3 ++- app/assets/stylesheets/single-post-view.scss | 5 +++++ app/assets/templates/status-message_tpl.jst.hbs | 10 +++++++++- spec/javascripts/app/views/content_view_spec.js | 15 +++++++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 877376fd1..6ace83e70 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ * Remove some old temporary workarounds [#5964](https://github.com/diaspora/diaspora/pull/5964) * Remove unused `hasPhotos` and `hasText` functions [#5969](https://github.com/diaspora/diaspora/pull/5969) * Replace foreman with eye [#5966](https://github.com/diaspora/diaspora/pull/5966) +* Improved handling of reshares with deleted roots [#5968](https://github.com/diaspora/diaspora/pull/5968) ## Bug fixes * Disable auto follow back on aspect deletion [#5846](https://github.com/diaspora/diaspora/pull/5846) diff --git a/app/assets/javascripts/app/views/content_view.js b/app/assets/javascripts/app/views/content_view.js index 75a4632cc..e93f6bfa6 100644 --- a/app/assets/javascripts/app/views/content_view.js +++ b/app/assets/javascripts/app/views/content_view.js @@ -10,7 +10,8 @@ app.views.Content = app.views.Base.extend({ text : app.helpers.textFormatter(this.model.get("text"), this.model.get("mentioned_people")), largePhoto : this.largePhoto(), smallPhotos : this.smallPhotos(), - location: this.location() + location: this.location(), + isReshare : this.model.get("post_type") === "Reshare" }); }, diff --git a/app/assets/stylesheets/single-post-view.scss b/app/assets/stylesheets/single-post-view.scss index c5a5684a1..7ddcb9576 100644 --- a/app/assets/stylesheets/single-post-view.scss +++ b/app/assets/stylesheets/single-post-view.scss @@ -98,6 +98,11 @@ padding-top: 20px; width: auto; + #real-post-content div.reshare { + border-left: 2px solid #DDD; + padding-left: 10px; + } + .oembed { width: 95%; } .photo_attachments { img.big_stream_photo { max-width: 90%; } diff --git a/app/assets/templates/status-message_tpl.jst.hbs b/app/assets/templates/status-message_tpl.jst.hbs index a750289cc..f6689bf30 100644 --- a/app/assets/templates/status-message_tpl.jst.hbs +++ b/app/assets/templates/status-message_tpl.jst.hbs @@ -16,7 +16,15 @@
- {{{text}}} + {{#if text}} + {{{text}}} + {{else if isReshare}} +
+

+ {{t "stream.original_post_deleted"}} +

+
+ {{/if}}
diff --git a/spec/javascripts/app/views/content_view_spec.js b/spec/javascripts/app/views/content_view_spec.js index 8f42a247f..6a701aaa3 100644 --- a/spec/javascripts/app/views/content_view_spec.js +++ b/spec/javascripts/app/views/content_view_spec.js @@ -10,4 +10,19 @@ describe("app.views.Content", function(){ expect(this.view.smallPhotos().length).toEqual(1); }); }); + + describe("presenter", function(){ + beforeEach(function(){ + this.post.set({text : ""}); // for textFormatter + }); + + it("provides isReshare", function(){ + expect(this.view.presenter().isReshare).toBeFalsy(); + }); + + it("provides isReshare and be true when the post is a reshare", function(){ + this.post.set({post_type : "Reshare"}); + expect(this.view.presenter().isReshare).toBeTruthy(); + }); + }); });