Skip to content
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
5 changes: 5 additions & 0 deletions template/inbox/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,11 @@ async function sendStatusUpdateToBuyer(msg, newStatus, updateBtn) {
return;
}

if (pendingStatusUpdateUid) {
console.warn('sendStatusUpdateToBuyer: previous send still pending, skipping');
return;
}

try {
if (!myPublicKey) {
myPublicKey = await getMyPublicKey();
Expand Down
8 changes: 4 additions & 4 deletions template/shop/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,8 @@ function renderInbox() {
setupInboxEventListeners();
}

const STATUS_ICONS = { PENDING: '⏳', PAID: '💳', CONFIRMED: '✅', SHIPPED: '🚚', DELIVERED: '📦' };

function renderMessageList(messages, type) {
if (messages.length === 0) {
return `
Expand All @@ -1828,8 +1830,7 @@ function renderMessageList(messages, type) {
const isReply = msg.type === 'REPLY';
const isBuyerReply = msg.type === 'BUYER_REPLY';
const isStatusUpdate = msg.type === 'STATUS_UPDATE';
const statusIcons = { PENDING: '⏳', PAID: '💳', CONFIRMED: '✅', SHIPPED: '🚚', DELIVERED: '📦' };
const statusIcon = isStatusUpdate ? (statusIcons[msg.product] || '📋') : null;
const statusIcon = isStatusUpdate ? (STATUS_ICONS[msg.product] || '📋') : null;
return `
<div class="message-item ${msg.direction === 'received' && !msg.read ? 'unread' : ''} ${isBuyerReply ? 'buyer-reply' : ''}" data-id="${msg.id}">
<div class="message-icon">${isStatusUpdate ? statusIcon : (isBuyerReply ? '↩️' : (isReply ? '↩️' : (msg.direction === 'received' ? '📨' : '📤')))}</div>
Expand Down Expand Up @@ -1858,8 +1859,7 @@ function renderMessageDetail(msg) {

// Status update notification (received)
if (isStatusUpdate) {
const statusIcons = { PENDING: '⏳', PAID: '💳', CONFIRMED: '✅', SHIPPED: '🚚', DELIVERED: '📦' };
const statusIcon = statusIcons[msg.product] || '📋';
const statusIcon = STATUS_ICONS[msg.product] || '📋';
const statusLabel = msg.product
? msg.product.charAt(0) + msg.product.slice(1).toLowerCase()
: 'Updated';
Expand Down
5 changes: 3 additions & 2 deletions template/shop/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function saveMessageToDb(message) {
MDS.sql(
'INSERT OR IGNORE INTO messages ' +
'(randomid, ref, type, product, size, amount, currency, delivery, shipping, message, ' +
'timestamp, coinid, read, direction, buyerPublicKey, buyerAddress, vendorPublicKey, vendorAddress) ' +
'timestamp, coinid, read, direction, buyerPublicKey, buyerAddress, vendorPublicKey, vendorAddress, subject) ' +
'VALUES (' +
escapeSQL(message.randomid || generateRandomId()) + ', ' +
escapeSQL(message.ref || '') + ', ' + escapeSQL(message.type || 'ORDER') + ', ' +
Expand All @@ -97,7 +97,8 @@ function saveMessageToDb(message) {
escapeSQL(message.coinid || '') + ', ' + (message.read ? 1 : 0) + ', ' +
escapeSQL(message.direction || 'sent') + ', ' +
escapeSQL(message.buyerPublicKey || '') + ', ' + escapeSQL(message.buyerAddress || '') + ', ' +
escapeSQL(message.vendorPublicKey || '') + ', ' + escapeSQL(message.vendorAddress || '') + ')',
escapeSQL(message.vendorPublicKey || '') + ', ' + escapeSQL(message.vendorAddress || '') + ', ' +
escapeSQL(message.subject || '') + ')',
function(response) {
if (response && response.status) {
console.log('SVC shop: saved msg to DB:', message.ref || message.randomid);
Expand Down
Loading