Browse Source

fix remove text when modal closes

pull/127/head
Phillip Lang Martinez 2 years ago
parent
commit
51bc261452
  1. 20
      qortal-ui-plugins/plugins/core/components/ChatPage.js
  2. 21
      qortal-ui-plugins/plugins/core/components/ChatTextEditor.js

20
qortal-ui-plugins/plugins/core/components/ChatPage.js

@ -654,7 +654,10 @@ class ChatPage extends LitElement {
</div>
`: ''}
<wrapper-modal
.removeImage=${() => this.removeImage()}
.removeImage=${() => {
this.chatEditorNewChat.resetValue()
this.removeImage()
} }
style=${(this.imageFile && !this.isUploadingImage) ? "display: block" : "display: none"}>
<div>
<div class="dialog-container">
@ -673,17 +676,23 @@ class ChatPage extends LitElement {
.insertImage=${this.insertImage}
.editedMessageObj=${this.editedMessageObj}
?isLoading=${this.isLoading}
?isLoadingMessages=${this.isLoadingMessages}>
?isLoadingMessages=${this.isLoadingMessages}
id="chatTextCaption"
>
</chat-text-editor>
</div>
<div class="modal-button-row">
<button class="modal-button-red" @click=${() => this.removeImage()}>
<button class="modal-button-red" @click=${() => {
this.chatEditorNewChat.resetValue()
this.removeImage()
}}>
${translate("chatpage.cchange33")}
</button>
<button
class="modal-button"
@click=${()=> {
this._sendMessage({
const chatTextEditor = this.shadowRoot.getElementById('chatTextCaption')
chatTextEditor.sendMessageFunc({
type: 'image',
imageFile: this.imageFile,
})
@ -699,6 +708,8 @@ class ChatPage extends LitElement {
`
}
showLastMessageRefScroller(props) {
this.lastMessageRefVisible = props;
}
@ -1700,6 +1711,7 @@ class ChatPage extends LitElement {
const getSendChatResponse = (response) => {
if (response === true) {
this.chatEditor.resetValue();
this.chatEditorNewChat.resetValue()
} else if (response.error) {
parentEpml.request('showSnackBar', response.message);
} else {

21
qortal-ui-plugins/plugins/core/components/ChatTextEditor.js

@ -150,6 +150,7 @@ class ChatTextEditor extends LitElement {
this.isLoading = false
this.getMessageSize = this.getMessageSize.bind(this)
this.calculateIFrameHeight = this.calculateIFrameHeight.bind(this)
this.resetIFrameHeight = this.resetIFrameHeight.bind(this)
this.addGlobalEventListener = this.addGlobalEventListener.bind(this)
this.sendMessageFunc = this.sendMessageFunc.bind(this)
this.removeGlobalEventListener = this.removeGlobalEventListener.bind(this)
@ -402,6 +403,17 @@ class ChatTextEditor extends LitElement {
...message,
messageText: trimmedMessage,
}
} else if(this.imageFile && this.iframeId === 'newChat') {
messageObject = {
messageText: trimmedMessage,
images: [{
service: "QCHAT_IMAGE",
name: '123456789123456789123456789',
identifier: '123456'
}],
repliedTo: '',
version: 1
};
} else {
messageObject = {
messageText: trimmedMessage,
@ -426,7 +438,9 @@ class ChatTextEditor extends LitElement {
this.iframeHeight = editorTest + 20;
}, 50)
}
resetIFrameHeight(height) {
this.iframeHeight = 42;
}
initChatEditor() {
const ChatEditor = function (editorConfig) {
const ChatEditor = function () {
@ -458,7 +472,7 @@ class ChatTextEditor extends LitElement {
editor.contentDiv.innerHTML = '';
editor.updateMirror();
editor.focus();
editorConfig.calculateIFrameHeight()
editorConfig.resetIFrameHeight()
};
ChatEditor.prototype.styles = function () {
@ -802,7 +816,8 @@ class ChatTextEditor extends LitElement {
addGlobalEventListener: this.addGlobalEventListener,
removeGlobalEventListener: this.removeGlobalEventListener,
iframeId: this.iframeId,
theme: this.theme
theme: this.theme,
resetIFrameHeight: this.resetIFrameHeight
};
const newChat = new ChatEditor(editorConfig);
this.setChatEditor(newChat);

Loading…
Cancel
Save