chatference, switch reference for signature

This commit is contained in:
Phillip 2023-02-02 11:34:38 +02:00
parent 8fca4f27d4
commit ce442dee1b
4 changed files with 19 additions and 19 deletions

View File

@ -1510,7 +1510,7 @@ class ChatPage extends LitElement {
}
async goToRepliedMessage(message, clickedOnMessage){
const findMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(message.reference)
const findMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(message.signature)
if(findMessage){
findMessage.scrollIntoView({ behavior: 'smooth', block: 'center' })
@ -1534,7 +1534,7 @@ class ChatPage extends LitElement {
if((message.timestamp - this.messagesRendered[0].timestamp) < 86400000){
const findOriginalMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(clickedOnMessage.reference)
const findOriginalMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(clickedOnMessage.signature)
if(findOriginalMessage){
const messageClientRect = findOriginalMessage.getBoundingClientRect()
this.isLoadingGoToRepliedMessage = {
@ -1546,7 +1546,7 @@ class ChatPage extends LitElement {
}
}
await this.getOldMessageDynamic(0, this.messagesRendered[0].timestamp, message.timestamp - 7200000)
const findMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(message.reference)
const findMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(message.signature)
if(findMessage){
this.isLoadingGoToRepliedMessage = {
...this.isLoadingGoToRepliedMessage,
@ -2014,7 +2014,7 @@ class ChatPage extends LitElement {
await this.getUpdateComplete();
const marginElements = Array.from(this.shadowRoot.querySelector('chat-scroller').shadowRoot.querySelectorAll('message-template'));
const findElement = marginElements.find((item)=> item.messageObj.reference === scrollElement.messageObj.reference)
const findElement = marginElements.find((item)=> item.messageObj.signature === scrollElement.messageObj.signature)
if(findElement){
findElement.scrollIntoView({ behavior: 'auto', block: 'center' });
@ -2047,7 +2047,7 @@ class ChatPage extends LitElement {
this.isLoadingOldMessages = false
await this.getUpdateComplete();
const marginElements = Array.from(this.shadowRoot.querySelector('chat-scroller').shadowRoot.querySelectorAll('message-template'));
const findElement = marginElements.find((item)=> item.messageObj.reference === scrollElement.messageObj.reference)
const findElement = marginElements.find((item)=> item.messageObj.signature === scrollElement.messageObj.signature)
if(findElement){
findElement.scrollIntoView({ behavior: 'auto', block: 'center' });
@ -2085,7 +2085,7 @@ class ChatPage extends LitElement {
await this.getUpdateComplete();
const marginElements = Array.from(this.shadowRoot.querySelector('chat-scroller').shadowRoot.querySelectorAll('message-template'));
const findElement = marginElements.find((item)=> item.messageObj.reference === scrollElement.messageObj.reference)
const findElement = marginElements.find((item)=> item.messageObj.signature === scrollElement.messageObj.signature)
if(findElement){
findElement.scrollIntoView({ behavior: 'auto', block: 'center' });
@ -2118,7 +2118,7 @@ class ChatPage extends LitElement {
this.isLoadingOldMessages = false
await this.getUpdateComplete();
const marginElements = Array.from(this.shadowRoot.querySelector('chat-scroller').shadowRoot.querySelectorAll('message-template'));
const findElement = marginElements.find((item)=> item.messageObj.reference === scrollElement.messageObj.reference)
const findElement = marginElements.find((item)=> item.messageObj.signature === scrollElement.messageObj.signature)
if(findElement){
findElement.scrollIntoView({ behavior: 'auto', block: 'center' });
@ -2224,7 +2224,7 @@ class ChatPage extends LitElement {
async renderNewMessage(newMessage) {
if(newMessage.chatReference){
const findOriginalMessageIndex = this.messagesRendered.findIndex(msg=> msg.reference === newMessage.chatReference || (msg.chatReference && msg.chatReference === newMessage.chatReference) )
const findOriginalMessageIndex = this.messagesRendered.findIndex(msg=> msg.signature === newMessage.chatReference || (msg.chatReference && msg.chatReference === newMessage.chatReference) )
if(findOriginalMessageIndex !== -1){
const newMessagesRendered = [...this.messagesRendered]
newMessagesRendered[findOriginalMessageIndex] = {...newMessage, timestamp: newMessagesRendered[findOriginalMessageIndex].timestamp, senderName: newMessagesRendered[findOriginalMessageIndex].senderName,
@ -2632,7 +2632,7 @@ class ChatPage extends LitElement {
return
}
typeMessage = 'edit';
let chatReference = outSideMsg.editedMessageObj.reference;
let chatReference = outSideMsg.editedMessageObj.signature;
if(outSideMsg.editedMessageObj.chatReference){
chatReference = outSideMsg.editedMessageObj.chatReference;
@ -2737,7 +2737,7 @@ class ChatPage extends LitElement {
} else if (outSideMsg && outSideMsg.type === 'reaction') {
const userName = await getName(this.selectedAddress.address);
typeMessage = 'edit';
let chatReference = outSideMsg.editedMessageObj.reference;
let chatReference = outSideMsg.editedMessageObj.signature;
if (outSideMsg.editedMessageObj.chatReference) {
chatReference = outSideMsg.editedMessageObj.chatReference;
@ -2795,7 +2795,7 @@ class ChatPage extends LitElement {
}
else if (this.repliedToMessageObj) {
let chatReference = this.repliedToMessageObj.reference;
let chatReference = this.repliedToMessageObj.signature;
if(this.repliedToMessageObj.chatReference){
chatReference = this.repliedToMessageObj.chatReference;
}
@ -2810,7 +2810,7 @@ class ChatPage extends LitElement {
this.sendMessage(stringifyMessageObject, typeMessage);
} else if (this.editedMessageObj) {
typeMessage = 'edit'
let chatReference = this.editedMessageObj.reference
let chatReference = this.editedMessageObj.signature
if(this.editedMessageObj.chatReference){
chatReference = this.editedMessageObj.chatReference

View File

@ -123,7 +123,7 @@ class ChatScroller extends LitElement {
${formattedMessages.map((formattedMessage) => {
return repeat(
formattedMessage.messages,
(message) => message.reference,
(message) => message.signature,
(message, indexMessage) => html`
<message-template
.emojiPicker=${this.emojiPicker}
@ -143,7 +143,7 @@ class ChatScroller extends LitElement {
.setOpenTipUser=${(val) => this.setOpenTipUser(val)}
.setOpenUserInfo=${(val) => this.setOpenUserInfo(val)}
.setUserName=${(val) => this.setUserName(val)}
id=${message.reference}
id=${message.signature}
.goToRepliedMessage=${this.goToRepliedMessage}
.addSeenMessage=${(val)=> this.addSeenMessage(val)}
.listSeenMessages=${this.listSeenMessages}
@ -346,7 +346,7 @@ class MessageTemplate extends LitElement {
firstUpdated(){
const autoSeeChatList = window.parent.reduxStore.getState().app?.autoLoadImageChats
if(autoSeeChatList.includes(this.chatId) || this.listSeenMessages.includes(this.messageObj.reference)){
if(autoSeeChatList.includes(this.chatId) || this.listSeenMessages.includes(this.messageObj.signature)){
this.viewImage = true
}
@ -590,7 +590,7 @@ class MessageTemplate extends LitElement {
<div
@click=${()=> {
this.viewImage = true
this.addSeenMessage(this.messageObj.reference)
this.addSeenMessage(this.messageObj.signature)
}}
class=${[`image-container`, !this.isImageLoaded ? 'defaultSize' : ''].join(' ')}
style=${this.isFirstMessage && "margin-top: 10px;"}>

View File

@ -659,7 +659,7 @@ mwc-checkbox::shadow .mdc-checkbox::after, mwc-checkbox::shadow .mdc-checkbox::b
let messageObject = {};
if (this.repliedToMessageObj) {
let chatReference = this.repliedToMessageObj.reference;
let chatReference = this.repliedToMessageObj.signature;
if (this.repliedToMessageObj.chatReference) {
chatReference = this.repliedToMessageObj.chatReference;
}

View File

@ -14,7 +14,7 @@ export const replaceMessagesEdited = async ({
}
const response = await parentEpml.request("apiCall", {
type: "api",
url: `/chat/messages?chatreference=${msg.reference}&reverse=true${msgQuery}`,
url: `/chat/messages?chatreference=${msg.signature}&reverse=true${msgQuery}`,
})
if (response && Array.isArray(response) && response.length !== 0) {
@ -52,7 +52,7 @@ export const replaceMessagesEdited = async ({
if (parsedMessageObj.repliedTo) {
const originalReply = await parentEpml.request("apiCall", {
type: "api",
url: `/chat/messages?reference=${parsedMessageObj.repliedTo}&reverse=true${msgQuery}`,
url: `/chat/messages?signature=${parsedMessageObj.repliedTo}&reverse=true${msgQuery}`,
})
const response = await parentEpml.request("apiCall", {
type: "api",