Set participations client side when changing post interactions
closes #7040
This commit is contained in:
parent
02742a4a8f
commit
9a2cb1517a
5 changed files with 40 additions and 6 deletions
|
|
@ -6,10 +6,11 @@
|
||||||
* Make the session cookies HttpOnly again [#7041](https://github.com/diaspora/diaspora/pull/7041)
|
* Make the session cookies HttpOnly again [#7041](https://github.com/diaspora/diaspora/pull/7041)
|
||||||
|
|
||||||
## Bug fixes
|
## Bug fixes
|
||||||
* Post comments no longer get collapsed when interacting with a post [#7045](https://github.com/diaspora/diaspora/pull/7045)
|
* Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* The "subscribe" indicator on a post now gets toggled when you like or rehsare a post [#7045](https://github.com/diaspora/diaspora/pull/7045)
|
* Deleted comments will be removed when loading more comments [#7045](https://github.com/diaspora/diaspora/pull/7045)
|
||||||
|
* The "subscribe" indicator on a post now gets toggled when you like or rehsare a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
|
||||||
|
|
||||||
# 0.6.0.0
|
# 0.6.0.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ app.models.Post.Interactions = Backbone.Model.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
this.likes.create({}, {
|
this.likes.create({}, {
|
||||||
success: function() {
|
success: function() {
|
||||||
|
self.post.set({participation: true});
|
||||||
self.trigger("change");
|
self.trigger("change");
|
||||||
self.set({"likes_count" : self.get("likes_count") + 1});
|
self.set({"likes_count" : self.get("likes_count") + 1});
|
||||||
},
|
},
|
||||||
|
|
@ -94,6 +95,7 @@ app.models.Post.Interactions = Backbone.Model.extend({
|
||||||
this.comments.make(text).fail(function () {
|
this.comments.make(text).fail(function () {
|
||||||
app.flashMessages.error(Diaspora.I18n.t("failed_to_comment"));
|
app.flashMessages.error(Diaspora.I18n.t("failed_to_comment"));
|
||||||
}).done(function() {
|
}).done(function() {
|
||||||
|
self.post.set({participation: true});
|
||||||
self.trigger('change'); //updates after sync
|
self.trigger('change'); //updates after sync
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -109,6 +111,7 @@ app.models.Post.Interactions = Backbone.Model.extend({
|
||||||
.done(function(reshare) {
|
.done(function(reshare) {
|
||||||
app.flashMessages.success(Diaspora.I18n.t("reshares.successful"));
|
app.flashMessages.success(Diaspora.I18n.t("reshares.successful"));
|
||||||
interactions.reshares.add(reshare);
|
interactions.reshares.add(reshare);
|
||||||
|
interactions.post.set({participation: true});
|
||||||
if (app.stream && /^\/(?:stream|activity|aspects)/.test(app.stream.basePath())) {
|
if (app.stream && /^\/(?:stream|activity|aspects)/.test(app.stream.basePath())) {
|
||||||
app.stream.addNow(reshare);
|
app.stream.addNow(reshare);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,11 @@ Feature: Liking posts
|
||||||
And I sign in as "alice@alice.alice"
|
And I sign in as "alice@alice.alice"
|
||||||
|
|
||||||
Scenario: Liking and unliking a post from the stream
|
Scenario: Liking and unliking a post from the stream
|
||||||
|
Then I should not have activated notifications for the post
|
||||||
When I like the post "I like unicorns" in the stream
|
When I like the post "I like unicorns" in the stream
|
||||||
Then I should see "Unlike" within ".stream_element .feedback"
|
Then I should see "Unlike" within ".stream_element .feedback"
|
||||||
And I should see a ".likes .media" within "#main_stream .stream_element"
|
And I should see a ".likes .media" within "#main_stream .stream_element"
|
||||||
|
And I should have activated notifications for the post
|
||||||
|
|
||||||
When I unlike the post "I like unicorns" in the stream
|
When I unlike the post "I like unicorns" in the stream
|
||||||
Then I should see "Like" within ".stream_element .feedback"
|
Then I should see "Like" within ".stream_element .feedback"
|
||||||
|
|
@ -25,8 +27,10 @@ Feature: Liking posts
|
||||||
|
|
||||||
Scenario: Liking and unliking a post from a single post page
|
Scenario: Liking and unliking a post from a single post page
|
||||||
When I open the show page of the "I like unicorns" post
|
When I open the show page of the "I like unicorns" post
|
||||||
And I click to like the post
|
Then I should not have activated notifications for the post in the single post view
|
||||||
|
When I click to like the post
|
||||||
Then I should see a ".count" within "#single-post-interactions"
|
Then I should see a ".count" within "#single-post-interactions"
|
||||||
|
And I should have activated notifications for the post in the single post view
|
||||||
|
|
||||||
When I click to unlike the post
|
When I click to unlike the post
|
||||||
Then I should not see a ".count" within "#single-post-interactions"
|
Then I should not see a ".count" within "#single-post-interactions"
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,14 @@ end
|
||||||
When /^I filter notifications by mentions$/ do
|
When /^I filter notifications by mentions$/ do
|
||||||
step %(I follow "Mentioned" within "#notifications_container .list-group")
|
step %(I follow "Mentioned" within "#notifications_container .list-group")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^I should( not)? have activated notifications for the post( in the single post view)?$/ do |negate, spv|
|
||||||
|
selector = spv ? "#single-post-moderation" : "#main_stream .stream_element"
|
||||||
|
if negate
|
||||||
|
expect(find(selector, match: :first)).to have_no_css(".destroy_participation", visible: false)
|
||||||
|
expect(find(selector, match: :first)).to have_css(".create_participation", visible: false)
|
||||||
|
else
|
||||||
|
expect(find(selector, match: :first)).to have_css(".destroy_participation", visible: false)
|
||||||
|
expect(find(selector, match: :first)).to have_no_css(".create_participation", visible: false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
describe("app.models.Post.Interactions", function(){
|
describe("app.models.Post.Interactions", function(){
|
||||||
|
var ajaxSuccess = {status: 200, responseText: "{\"id\": 1}"};
|
||||||
|
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
this.interactions = factory.post().interactions;
|
this.post = factory.post();
|
||||||
|
this.interactions = this.post.interactions;
|
||||||
this.author = factory.author({guid: "loggedInAsARockstar"});
|
this.author = factory.author({guid: "loggedInAsARockstar"});
|
||||||
loginAs({guid: "loggedInAsARockstar"});
|
loginAs({guid: "loggedInAsARockstar"});
|
||||||
|
|
||||||
|
|
@ -30,6 +33,13 @@ describe("app.models.Post.Interactions", function(){
|
||||||
this.interactions.like();
|
this.interactions.like();
|
||||||
expect(this.interactions.likes.length).toEqual(1);
|
expect(this.interactions.likes.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("sets the participation flag for the post", function() {
|
||||||
|
expect(this.post.get("participation")).toBeFalsy();
|
||||||
|
this.interactions.like();
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith(ajaxSuccess);
|
||||||
|
expect(this.post.get("participation")).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("unlike", function(){
|
describe("unlike", function(){
|
||||||
|
|
@ -42,8 +52,6 @@ describe("app.models.Post.Interactions", function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("reshare", function() {
|
describe("reshare", function() {
|
||||||
var ajaxSuccess = { status: 200, responseText: "{\"id\": 1}" };
|
|
||||||
|
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
this.reshare = this.interactions.post.reshare();
|
this.reshare = this.interactions.post.reshare();
|
||||||
});
|
});
|
||||||
|
|
@ -81,6 +89,13 @@ describe("app.models.Post.Interactions", function(){
|
||||||
expect(app.stream.addNow).not.toHaveBeenCalled();
|
expect(app.stream.addNow).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("sets the participation flag for the post", function() {
|
||||||
|
expect(this.post.get("participation")).toBeFalsy();
|
||||||
|
this.interactions.reshare();
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith(ajaxSuccess);
|
||||||
|
expect(this.post.get("participation")).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("userLike", function(){
|
describe("userLike", function(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue