Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

Changes logic to handle both upper and lower case on all dispute mess… #1834

Merged
merged 1 commit into from
Nov 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/templates/notification.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<%= polyglot.t('NotificationOrderConfirmed') %>
</div>
<div class="textSize11px floatLeft txt-fade"><%= ob.moment(new Date(ob.timestamp*1000)).locale(window.lang).format('MMM D, h:mm A') %></div>
<% } else if(ob.type == "dispute_close") { %>
<% } else if(ob.type == "DISPUTE_CLOSE" || ob.type == "dispute_close") { %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern as on the other PR. If indeed the server is inconsistently sending types with different case, then the bug should be on the server. IMHO, it's poor practice to complicate a client code base to account for fixable defects in the server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the server currently only sends upper case, handling lower case was left in because it was there before, and I didn't want to add a new bug in the 1.1.9 release.

<div class="textSize12px row5">
<% if(ob.handle) { %>
<%= polyglot.t('NotificationDisputeClosed',{name: ob.handle}) %>
Expand All @@ -24,7 +24,7 @@
<% } %>
</div>
<div class="textSize11px floatLeft txt-fade"><%= ob.moment(new Date(ob.timestamp*1000)).locale(window.lang).format('MMM D, h:mm A') %></div>
<% } else if(ob.type == "dispute_open") { %>
<% } else if(ob.type == "DISPUTE_OPEN" || ob.type == "dispute_open") { %>
<div class="textSize12px row5">
<% if(ob.handle) { %>
<%= polyglot.t('NotificationDispute',{name:ob.handle}) %>
Expand Down
58 changes: 29 additions & 29 deletions js/views/notificationVw.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ module.exports = baseVw.extend({
},

notificationClick: function() {
switch (this.model.get('type')) {
case "follow":
Backbone.history.navigate('#userPage/'+ this.model.get('guid') + '/store', {trigger: true});
break;
case "new order":
Backbone.history.navigate('#transactions/sales/' + this.model.get('order_id'), {trigger: true});
break;
case "dispute_open":
Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "dispute_close":
Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "refund":
Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "payment received":
Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "order confirmation":
Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "rating received":
Backbone.history.navigate('#transactions/sales/' + this.model.get('order_id'), {trigger: true});
break;
case "ORDER":
Backbone.history.navigate('#transactions/sales/' + this.model.get('subject') +'/discussion', {trigger: true});
break;
switch (this.model.get('type').toLowerCase()) {
case "follow":
Backbone.history.navigate('#userPage/'+ this.model.get('guid') + '/store', {trigger: true});
break;
case "new order":
Backbone.history.navigate('#transactions/sales/' + this.model.get('order_id'), {trigger: true});
break;
case "dispute_open":
Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "dispute_close":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the server ticket, I would also request consistency in format beyond case. For example, some types have underscores for spaces (dispute_close) whereas others use actual spaces (new order).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be good, the messages don't have much consistency.

Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "refund":
Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "payment received":
Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "order confirmation":
Backbone.history.navigate('#transactions/purchases/' + this.model.get('order_id'), {trigger: true});
break;
case "rating received":
Backbone.history.navigate('#transactions/sales/' + this.model.get('order_id'), {trigger: true});
break;
case "order":
Backbone.history.navigate('#transactions/sales/' + this.model.get('subject') +'/discussion', {trigger: true});
break;
}

this.trigger('notification-click', { view: this });
Expand All @@ -61,4 +61,4 @@ module.exports = baseVw.extend({

return this;
}
});
});
4 changes: 2 additions & 2 deletions js/views/pageNavVw.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ module.exports = baseVw.extend({
})
);

switch (notif.type) {
switch (notif.type.toLowerCase()) {
case "follow":
new Notification(window.polyglot.t('NotificationFollow', {name: username}), {
icon: avatar,
Expand Down Expand Up @@ -289,7 +289,7 @@ module.exports = baseVw.extend({
silent: true
});
break;
case "ORDER":
case "order":
new Notification(window.polyglot.t('NotificationNewTransactionMessage', {name: username}), {
icon: avatar,
silent: true
Expand Down