Skip to content

Commit 6e86007

Browse files
svbergeremfrankrousseau
authored andcommitted
Fix first comment in mobile view with french locale
Fixes diaspora#7438. The regression has possibly been introduced by diaspora#7207. closes diaspora#7441
1 parent fe499fb commit 6e86007

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
## Bug fixes
2626
* Make photo upload button hover text translatable [#7429](https://github.com/diaspora/diaspora/pull/7429)
27+
* Fix first comment in mobile view with french locale [#7441](https://github.com/diaspora/diaspora/pull/7441)
2728

2829
## Features
2930

app/assets/javascripts/mobile/mobile_comments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
increaseReactionCount: function(bottomBar) {
202202
var toggleReactionsLink = bottomBar.find(".show-comments").first();
203203
var count = toggleReactionsLink.text().match(/.*(\d+).*/);
204-
count = parseInt(count, 10);
204+
count = parseInt(count, 10) || 0;
205205
var text = Diaspora.I18n.t("stream.comments", {count: count + 1});
206206

207207
// No previous comment

spec/javascripts/mobile/mobile_comments_spec.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe("Diaspora.Mobile.Comments", function(){
144144
expect(this.toggleReactionsLink.text().trim()).toBe("6 comments");
145145
});
146146

147-
it("Creates the reaction link when no reactions", function(){
147+
it("Creates the reaction link when there are no reactions", function() {
148148
var parent = this.toggleReactionsLink.parent();
149149
var postGuid = this.bottomBar.parents(".stream-element").data("guid");
150150
this.toggleReactionsLink.remove();
@@ -155,6 +155,18 @@ describe("Diaspora.Mobile.Comments", function(){
155155
expect(this.toggleReactionsLink.text().trim()).toBe("1 comment");
156156
expect(this.toggleReactionsLink.attr("href")).toBe("/posts/" + postGuid + "/comments.mobile");
157157
});
158+
159+
it("Creates the reaction link when there are no reactions (french locale)", function() {
160+
var parent = this.toggleReactionsLink.parent();
161+
var postGuid = this.bottomBar.parents(".stream-element").data("guid");
162+
this.toggleReactionsLink.remove();
163+
parent.prepend($("<span/>", {"class": "show-comments"}).text("Aucun commentaire"));
164+
165+
Diaspora.Mobile.Comments.increaseReactionCount(this.bottomBar);
166+
this.toggleReactionsLink = this.bottomBar.find(".show-comments").first();
167+
expect(this.toggleReactionsLink.text().trim()).toBe("1 comment");
168+
expect(this.toggleReactionsLink.attr("href")).toBe("/posts/" + postGuid + "/comments.mobile");
169+
});
158170
});
159171

160172
describe("bottomBarLazy", function(){

0 commit comments

Comments
 (0)