diff --git a/static/components/chat-dialog/chat-dialog.html b/static/components/chat-dialog/chat-dialog.html
index e163c25..a88395a 100644
--- a/static/components/chat-dialog/chat-dialog.html
+++ b/static/components/chat-dialog/chat-dialog.html
@@ -41,10 +41,15 @@
:name="message.sender"
:text="[message.msg]"
:sent="message.sender == 'Me'"
- :bg-color="message.sender == 'Me' ? 'white' : 'light-green-2'"
+ :bg-color="message.json ? 'yellow-11' : message.sender == 'Me' ? 'white' : 'light-green-2'"
:stamp="message.timestamp"
size="6"
- />
+ >
+
diff --git a/static/components/chat-dialog/chat-dialog.js b/static/components/chat-dialog/chat-dialog.js
index 6cc42d9..83ed5ba 100644
--- a/static/components/chat-dialog/chat-dialog.js
+++ b/static/components/chat-dialog/chat-dialog.js
@@ -59,19 +59,41 @@ async function chatDialog(path) {
},
computed: {
sortedMessages() {
- return this.nostrMessages.sort((a, b) => b.created_at - a.created_at)
+ return this.nostrMessages
+ .map(m => {
+ if (!isJson(m.msg)) return m
+ let msg = JSON.parse(m.msg)
+ if (msg?.message) {
+ m.json = m.msg
+ m.msg = msg.message
+ return m
+ }
+ if (msg?.items) {
+ m.json = m.msg
+ m.msg = 'Order placed!'
+ return m
+ }
+ if (msg?.payment_options) {
+ m.json = m.msg
+ m.msg = '⚡︎ Invoice sent!'
+ return m
+ }
+ return m
+ })
+ .sort((a, b) => b.created_at - a.created_at)
},
ordersList() {
- let orders = this.nostrMessages
- .sort((a, b) => b.created_at - a.created_at)
- .filter(o => isJson(o.msg))
- .reduce((acc, cur) => {
- const obj = JSON.parse(cur.msg)
- const key = obj.id
- const curGroup = acc[key] ?? {created_at: cur.timestamp}
- return {...acc, [key]: {...curGroup, ...obj}}
- }, {})
- return Object.values(orders)
+ return Object.values(
+ this.nostrMessages
+ .sort((a, b) => b.created_at - a.created_at)
+ .filter(o => isJson(o.msg))
+ .reduce((acc, cur) => {
+ const obj = JSON.parse(cur.msg)
+ const key = obj.id
+ const curGroup = acc[key] ?? {created_at: cur.timestamp}
+ return {...acc, [key]: {...curGroup, ...obj}}
+ }, {})
+ )
}
},
methods: {