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

Commit 558be77

Browse files
committed
Code to add notifications of new transaction chats
1 parent 5ef7ede commit 558be77

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

js/languages/en-US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"GoToOneName": "Go to Onename.com",
3333
"GoToOneNameTooltip": "Create an ID at Onename.com, and under App Accounts enter openbazaar as the app name and your guid as the account identifier (your guid is on your page, in the About tab). Verification can take up to several days.",
3434
"ChangeCurrency": "Change currency",
35+
"ChangeCurrencyHelp": "Clicking this will take you to the settings view and will lose any changes you have made.",
3536
"SKU": "SKU",
3637
"Refurbished": "Refurbished",
3738
"Physical": "Physical",
@@ -220,6 +221,7 @@
220221
"NotificationRefund": "%{name} has refunded your order.",
221222
"NoticationOrderStatus": "Order status updated, buyer notified.",
222223
"NotificationNewOrder": "%{name} has made a purchase.",
224+
"NotificationNewTransactionMessage": "%{name} has sent you a new message about a transaction.",
223225
"NotificationTitle": "Title: %{title}",
224226
"NotificationFrom": "From: %{name}",
225227
"NotificationType": "Type: %{type}",

js/templates/itemEdit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ <h5><%= polyglot.t('Listing') %></h5>
9595
<%= polyglot.t('Price') %> (<%= ob.userCurrencyCode %>)
9696
</label>
9797
<div class="underline note rowTop5">
98-
<a href="#settings"><%= polyglot.t('ChangeCurrency') %></a>
98+
<a href="#settings" class="tooltip tooltip-box" data-tooltip="<%= polyglot.t('ChangeCurrencyHelp') %>"><%= polyglot.t('ChangeCurrency') %></a>
9999
</div>
100100
</div>
101101
</div>

js/templates/notification.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<% } %>
55
<div class="table">
66
<div>
7+
<% console.log(ob.type) %>
78
<div class="thumbnail clickable custcol-border"
89
style="background-image: <%= ob.cssImageUrl(ob.image_hash, ob.guid, 'imgs/defaultUser.png') %>; height: 50px; width: 50px"></div>
910
<div class="txt-lowleading">
@@ -35,6 +36,17 @@
3536
<% } %>
3637
</div>
3738
<div class="textSize11px floatLeft txt-fade"><%= ob.moment(new Date(ob.timestamp*1000)).format('MMM D, h:mm A') %></div>
39+
<% } else if(ob.type == "ORDER") { %>
40+
<div class="textSize12px row5">
41+
<% if(ob.handle) { %>
42+
<%= polyglot.t('NotificationNewTransactionMessage',{name:ob.handle}) %>
43+
<% }else{ %>
44+
<span class="inlineBlock top3">
45+
<%= polyglot.t('NotificationNewTransactionMessage',{name:ob.guid}) %>
46+
</span>
47+
<% } %>
48+
</div>
49+
<div class="textSize11px floatLeft txt-fade"><%= ob.moment(new Date(ob.timestamp*1000)).format('MMM D, h:mm A') %></div>
3850
<% } else if(ob.type == "payment received") { %>
3951
<div class="textSize12px row5">
4052
<% if(ob.handle) { %>

js/views/notificationVw.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ module.exports = baseVw.extend({
4545
case "rating received":
4646
Backbone.history.navigate('#transactions/sales/' + this.model.get('order_id'), {trigger: true});
4747
break;
48+
case "ORDER":
49+
Backbone.history.navigate('#transactions/sales/' + this.model.get('subject'), {trigger: true});
50+
break;
4851
}
4952

5053
this.trigger('notification-click', { view: this });

js/views/pageNavVw.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,18 @@ module.exports = baseVw.extend({
156156
username,
157157
avatar,
158158
notif,
159+
message,
159160
notifStamp;
160161

161-
if (data.hasOwnProperty('notification')) {
162-
notif = data.notification;
162+
if (data.hasOwnProperty('notification') || data.hasOwnProperty('message') && data.message.subject) {
163+
notif = data.notification || data.message;
163164
username = notif.handle ? notif.handle : notif.guid.substring(0,10) + '...';
164-
avatar = notif.image_hash ? app.serverConfig.getServerBaseUrl + '/get_image?hash=' +
165-
notif.image_hash + '&guid=' + notif.guid : 'imgs/defaultUser.png';
165+
avatar = notif.image_hash || notif.avatar_hash;
166+
avatar = avatar ? app.serverConfig.getServerBaseUrl + '/get_image?hash=' +
167+
avatar + '&guid=' + notif.guid : 'imgs/defaultUser.png';
168+
notif.type = notif.type || notif.message_type;
166169
notifStamp = Date.now();
167-
170+
168171
this.unreadNotifsViaSocket++;
169172

170173
this.notificationsCl.add(
@@ -193,6 +196,12 @@ module.exports = baseVw.extend({
193196
silent: true
194197
});
195198
break;
199+
case "dispute_close":
200+
new Notification(window.polyglot.t('NotificationDisputeClosed', {name: username}), {
201+
icon: avatar,
202+
silent: true
203+
});
204+
break;
196205
case "new order":
197206
new Notification(window.polyglot.t('NotificationNewOrder', {name: username}), {
198207
icon: avatar,
@@ -217,6 +226,12 @@ module.exports = baseVw.extend({
217226
silent: true
218227
});
219228
break;
229+
case "ORDER":
230+
new Notification(window.polyglot.t('NotificationNewTransactionMessage', {name: username}), {
231+
icon: avatar,
232+
silent: true
233+
});
234+
break;
220235
}
221236

222237
app.playNotificationSound();

0 commit comments

Comments
 (0)