From 063b4649b257430dc2ecd0b9cd62c4ab413af206 Mon Sep 17 00:00:00 2001 From: PhilReact Date: Thu, 14 Sep 2023 22:22:40 -0500 Subject: [PATCH] remove fixed username --- plugins/plugins/core/components/ChatPage.js | 6 ++++- .../plugins/core/components/ChatScroller.js | 26 ++++++++++++------- .../core/messaging/q-chat/q-chat.src.js | 15 ++++++++++- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/plugins/plugins/core/components/ChatPage.js b/plugins/plugins/core/components/ChatPage.js index c28565a8..3211d601 100644 --- a/plugins/plugins/core/components/ChatPage.js +++ b/plugins/plugins/core/components/ChatPage.js @@ -126,7 +126,9 @@ class ChatPage extends LitElement { updateMessageHash: { type: Object}, oldMessages: {type: Array}, messageQueue: {type: Array}, - isInProcessQueue: {type: Boolean} + isInProcessQueue: {type: Boolean}, + loggedInUserName: {type: String}, + loggedInUserAddress: {type: String} } } @@ -2610,6 +2612,8 @@ class ChatPage extends LitElement { .updateMessageHash=${this.updateMessageHash} .clearUpdateMessageHashmap=${this.clearUpdateMessageHashmap} .messageQueue=${this.messageQueue} + loggedInUserName=${this.loggedInUserName} + loggedInUserAddress=${this.loggedInUserAddress} > ` diff --git a/plugins/plugins/core/components/ChatScroller.js b/plugins/plugins/core/components/ChatScroller.js index a88d1eab..31077de1 100644 --- a/plugins/plugins/core/components/ChatScroller.js +++ b/plugins/plugins/core/components/ChatScroller.js @@ -46,6 +46,8 @@ const getApiKey = () => { return apiKey } + + const extractComponents = async (url) => { if (!url.startsWith("qortal://")) { return null @@ -246,7 +248,9 @@ class ChatScroller extends LitElement { disableFetching: {type: Boolean}, isLoadingBefore: {type: Boolean}, isLoadingAfter: {type: Boolean}, - messageQueue: {type: Array} + messageQueue: {type: Array}, + loggedInUserName: {type: String}, + loggedInUserAddress: {type: String} } } @@ -743,13 +747,11 @@ class ChatScroller extends LitElement { .emojiPicker=${this.emojiPicker} .escapeHTML=${this.escapeHTML} .messageObj=${{ - decodedMessage: message.messageText, - - "timestamp": message.timestamp, - "sender": "QWxEcmZxnM8yb1p92C1YKKRsp8svSVbFEs", - "senderName": "palmas", - "signature": "4B6hHMHTnSvXTMmQb73P4Yr2o772zu7XxiTiRQv8GsgysNaoc9UCUqb9x7ihz2Su6xCREZUvgACmFpHY2gzUbYHf", - + decodedMessage: message.messageText, + "timestamp": message.timestamp, + "sender": this.loggedInUserAddress, + "senderName": this.loggedInUserName, + "signature": "", }} .hideMessages=${this.hideMessages} .setRepliedToMessageObj=${this.setRepliedToMessageObj} @@ -796,6 +798,9 @@ class ChatScroller extends LitElement { if (changedProperties.has('userName')) { return true } + if(changedProperties.has('loggedInUserName')){ + return true + } if (changedProperties.has('updateMessageHash')) { return true } @@ -1557,7 +1562,8 @@ class MessageTemplate extends LitElement { - + `} +
diff --git a/plugins/plugins/core/messaging/q-chat/q-chat.src.js b/plugins/plugins/core/messaging/q-chat/q-chat.src.js index 7db50437..6a85446c 100644 --- a/plugins/plugins/core/messaging/q-chat/q-chat.src.js +++ b/plugins/plugins/core/messaging/q-chat/q-chat.src.js @@ -53,7 +53,9 @@ class Chat extends LitElement { userFoundModalOpen: { type: Boolean }, userSelected: { type: Object }, editor: {type: Object}, - groupInvites: { type: Array } + groupInvites: { type: Array }, + loggedInUserName: {type: String}, + loggedInUserAddress: {type: String}, } } @@ -92,6 +94,7 @@ class Chat extends LitElement { this.userFoundModalOpen = false this.userSelected = {} this.groupInvites = [] + this.loggedInUserName = "" } async setActiveChatHeadUrl(url) { @@ -145,6 +148,8 @@ class Chat extends LitElement { this.unsubscribeStore = window.parent.reduxStore.subscribe(() => { try { + const currentState = window.parent.reduxStore.getState(); + if(window.parent.location && window.parent.location.search) { const queryString = window.parent.location.search const params = new URLSearchParams(queryString) @@ -156,6 +161,12 @@ class Chat extends LitElement { this.setActiveChatHeadUrl(chat) } } + if(currentState.app.accountInfo && currentState.app.accountInfo.names && currentState.app.accountInfo.names.length > 0 && this.loggedInUserName !== currentState.app.accountInfo.names[0].name){ + this.loggedInUserName = currentState.app.accountInfo.names[0].name + } + if(currentState.app.accountInfo && currentState.app.accountInfo.addressInfo && currentState.app.accountInfo.addressInfo.address && this.loggedInUserAddress !== currentState.app.accountInfo.addressInfo.address){ + this.loggedInUserAddress = currentState.app.accountInfo.addressInfo.address + } } catch (error) { } }) @@ -831,6 +842,8 @@ class Chat extends LitElement { .setOpenPrivateMessage=${(val) => this.setOpenPrivateMessage(val)} .setActiveChatHeadUrl=${(val)=> this.setActiveChatHeadUrl(val)} balance=${this.balance} + loggedInUserName=${this.loggedInUserName} + loggedInUserAddress=${this.loggedInUserAddress} > `