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.id"></span>
</div>
<div v-else>
<span v-text="JSON.stringify(dm.message)"></span>
</div>
<q-badge @click="showMessageRawData(index)" class="cursor-pointer">...</q-badge>
</div>
</q-chat-message>
</div>
@ -88,5 +87,15 @@
</q-form>
</q-card>
</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>

View file

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