feat: show raw message data

This commit is contained in:
Vlad Stan 2023-07-03 17:38:44 +03:00
parent 13b19b672e
commit eccac69f7f
2 changed files with 27 additions and 12 deletions

View file

@ -57,9 +57,8 @@
<span v-text="dm.message.message"></span><br> <span v-text="dm.message.message"></span><br>
<span v-text="dm.message.id"></span> <span v-text="dm.message.id"></span>
</div> </div>
<div v-else> <q-badge @click="showMessageRawData(index)" class="cursor-pointer">...</q-badge>
<span v-text="JSON.stringify(dm.message)"></span>
</div>
</div> </div>
</q-chat-message> </q-chat-message>
</div> </div>
@ -88,5 +87,15 @@
</q-form> </q-form>
</q-card> </q-card>
</q-dialog> </q-dialog>
<q-dialog v-model="showRawMessage" position="top">
<q-card class="q-pa-lg q-pt-xl" style="width: 500px">
<q-input filled dense type="textarea" rows="20" v-model.trim="rawMessage" label="Raw Data"></q-input>
<div class="row q-mt-lg">
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Close</q-btn>
</div>
</q-form>
</q-card>
</q-dialog>
</div> </div>
</div> </div>

View file

@ -14,7 +14,7 @@ async function directMessages(path) {
} }
}, },
computed: { computed: {
messagesAsJson: function() { messagesAsJson: function () {
return this.messages.map(m => { return this.messages.map(m => {
try { try {
return { return {
@ -40,11 +40,13 @@ async function directMessages(path) {
messages: [], messages: [],
newMessage: '', newMessage: '',
showAddPublicKey: false, showAddPublicKey: false,
newPublicKey: null newPublicKey: null,
showRawMessage: false,
rawMessage: null,
} }
}, },
methods: { methods: {
sendMessage: async function () {}, sendMessage: async function () { },
buildCustomerLabel: function (c) { buildCustomerLabel: function (c) {
let label = `${c.profile.name || 'unknown'} ${c.profile.about || ''}` let label = `${c.profile.name || 'unknown'} ${c.profile.about || ''}`
if (c.unread_messages) { if (c.unread_messages) {
@ -61,7 +63,7 @@ async function directMessages(path) {
return return
} }
try { try {
const {data} = await LNbits.api.request( const { data } = await LNbits.api.request(
'GET', 'GET',
'/nostrmarket/api/v1/message/' + pubkey, '/nostrmarket/api/v1/message/' + pubkey,
this.inkey this.inkey
@ -75,7 +77,7 @@ async function directMessages(path) {
}, },
getCustomers: async function () { getCustomers: async function () {
try { try {
const {data} = await LNbits.api.request( const { data } = await LNbits.api.request(
'GET', 'GET',
'/nostrmarket/api/v1/customer', '/nostrmarket/api/v1/customer',
this.inkey this.inkey
@ -86,10 +88,10 @@ async function directMessages(path) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
} }
}, },
sendDirectMesage: async function () { sendDirectMesage: async function () {
try { try {
const {data} = await LNbits.api.request( const { data } = await LNbits.api.request(
'POST', 'POST',
'/nostrmarket/api/v1/message', '/nostrmarket/api/v1/message',
this.adminkey, this.adminkey,
@ -105,9 +107,9 @@ async function directMessages(path) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
} }
}, },
addPublicKey: async function(){ addPublicKey: async function () {
try { try {
const {data} = await LNbits.api.request( const { data } = await LNbits.api.request(
'POST', 'POST',
'/nostrmarket/api/v1/customer', '/nostrmarket/api/v1/customer',
this.adminkey, this.adminkey,
@ -141,6 +143,10 @@ async function directMessages(path) {
await this.getDirectMessages(this.activePublicKey) await this.getDirectMessages(this.activePublicKey)
await this.getCustomers() await this.getCustomers()
}, },
showMessageRawData: function (index) {
this.rawMessage = this.messages[index]?.message
this.showRawMessage = true
},
focusOnChatBox: function (index) { focusOnChatBox: function (index) {
setTimeout(() => { setTimeout(() => {
const lastChatBox = document.getElementsByClassName( const lastChatBox = document.getElementsByClassName(