From b6aa3aecaccdf272711fc1e33a0db8626702be8e Mon Sep 17 00:00:00 2001
From: Phillip Lang Martinez
Date: Mon, 26 Dec 2022 15:50:39 -0500
Subject: [PATCH] hide img from other users unless clicked
---
qortal-ui-core/language/us.json | 3 ++-
.../plugins/core/components/ChatScroller.js | 27 ++++++++++++++++---
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/qortal-ui-core/language/us.json b/qortal-ui-core/language/us.json
index 6bfec086..efeca99f 100644
--- a/qortal-ui-core/language/us.json
+++ b/qortal-ui-core/language/us.json
@@ -497,7 +497,8 @@
"cchange36": "Search Results",
"cchange37": "No Results Found",
"cchange38": "User Verified",
- "cchange39": "Cannot send an encrypted message to this user since they do not have their publickey on chain."
+ "cchange39": "Cannot send an encrypted message to this user since they do not have their publickey on chain.",
+ "cchange40": "IMAGE (click to view)"
},
"welcomepage": {
"wcchange1": "Welcome to Q-Chat",
diff --git a/qortal-ui-plugins/plugins/core/components/ChatScroller.js b/qortal-ui-plugins/plugins/core/components/ChatScroller.js
index 204b302d..39f9a01d 100644
--- a/qortal-ui-plugins/plugins/core/components/ChatScroller.js
+++ b/qortal-ui-plugins/plugins/core/components/ChatScroller.js
@@ -232,6 +232,7 @@ class MessageTemplate extends LitElement {
isLastMessageInGroup: { type: Boolean },
setToggledMessage: {attribute: false},
setForwardProperties: {attribute: false},
+ viewImage: {type: Boolean}
}
}
@@ -248,6 +249,7 @@ class MessageTemplate extends LitElement {
this.isFirstMessage = false
this.isSingleMessageInGroup = false
this.isLastMessageInGroup = false
+ this.viewImage = false
}
static styles = [chatStyles]
@@ -352,9 +354,13 @@ class MessageTemplate extends LitElement {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node];
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port;
imageUrl = `${nodeUrl}/arbitrary/${image.service}/${image.name}/${image.identifier}?async=true&apiKey=${myNode.apiKey}`;
- imageHTML = createImage(imageUrl);
- imageHTMLDialog = createImage(imageUrl);
- imageHTMLDialog.style= "height: auto; max-height: 80vh; width: auto; max-width: 80vw; object-fit: contain; border-radius: 5px";
+
+ if(this.viewImage || this.myAddress === this.messageObj.sender){
+ imageHTML = createImage(imageUrl);
+ imageHTMLDialog = createImage(imageUrl)
+ imageHTMLDialog.style= "height: auto; max-height: 80vh; width: auto; max-width: 80vw; object-fit: contain; border-radius: 5px";
+ }
+
}
nameMenu = html`
@@ -453,7 +459,20 @@ class MessageTemplate extends LitElement {
`}
- ${image && !isImageDeleted ? html`
+ ${image && !isImageDeleted && !this.viewImage && this.myAddress !== this.messageObj.sender ? html`
+ {
+ this.viewImage = true
+ }}
+ class=${[`image-container`, !this.isImageLoaded ? 'defaultSize' : ''].join(' ')}
+ style=${this.isFirstMessage && "margin-top: 10px;"}>
+
+ ${translate("chatpage.cchange40")}
+
+
+
+ ` : html``}
+ ${image && !isImageDeleted && (this.viewImage || this.myAddress === this.messageObj.sender) ? html`