From ddb91d22660379e128403b385c49afc882cf92d3 Mon Sep 17 00:00:00 2001 From: Phillip Date: Thu, 12 Jan 2023 17:42:03 -0500 Subject: [PATCH] remove unsued code --- .../plugins/core/components/ChatPage.js | 51 +++--------- .../core/components/ChatScroller-css.js | 1 + .../plugins/core/components/ChatScroller.js | 3 - .../plugins/core/components/ChatTextEditor.js | 81 +++---------------- 4 files changed, 21 insertions(+), 115 deletions(-) diff --git a/qortal-ui-plugins/plugins/core/components/ChatPage.js b/qortal-ui-plugins/plugins/core/components/ChatPage.js index b1b71914..bb5faf7e 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatPage.js +++ b/qortal-ui-plugins/plugins/core/components/ChatPage.js @@ -1,9 +1,7 @@ import { LitElement, html, css } from 'lit'; -import { render } from 'lit/html.js'; import {animate} from '@lit-labs/motion'; import { Epml } from '../../../epml.js'; import { use, get, translate, registerTranslateConfig } from 'lit-translate'; -import { chatStyles } from './ChatScroller-css.js' import { generateHTML } from '@tiptap/core' import StarterKit from '@tiptap/starter-kit' import Underline from '@tiptap/extension-underline'; @@ -18,7 +16,7 @@ registerTranslateConfig({ }); import ShortUniqueId from 'short-unique-id'; import Compressor from 'compressorjs'; -import { escape, unescape } from 'html-escaper'; +import { escape } from 'html-escaper'; import { inputKeyCodes } from '../../utils/keyCodes.js'; import './ChatScroller.js'; import './LevelFounder.js'; @@ -882,7 +880,6 @@ class ChatPage extends LitElement { } _toggle(value) { - console.log('toggel', value, this.shifted) this.shifted = value === (false || true) ? value : !this.shifted; this.requestUpdate() } @@ -901,10 +898,6 @@ class ChatPage extends LitElement {
- - - -
` : null} @@ -1232,7 +1225,6 @@ class ChatPage extends LitElement { } async getMoreMembers(groupId){ - console.log('getMoreMembers', groupId) try { const getMembers = await parentEpml.request("apiCall", { type: "api", @@ -1257,7 +1249,7 @@ class ChatPage extends LitElement { this.groupMembers = membersWithName this.pageNumber = this.pageNumber + 1 } catch (error) { - + console.error(error) } } @@ -1271,7 +1263,6 @@ class ChatPage extends LitElement { const elementChatId = this.shadowRoot.getElementById('_chatEditorDOM').shadowRoot.getElementById('_chatEditorDOM') const elementChatImageId = this.shadowRoot.getElementById('chatTextCaption').shadowRoot.getElementById('newChat') - console.log({elementChatId, elementChatImageId }) this.editor = new Editor({ onUpdate: ()=> { this.shadowRoot.getElementById('_chatEditorDOM').getMessageSize(this.editor.getJSON()) @@ -1330,7 +1321,6 @@ class ChatPage extends LitElement { disconnectedCallback() { super.disconnectedCallback(); - console.log('disconnected') this.webWorker.terminate(); this.webWorkerImage.terminate(); this.editor.destroy() @@ -1339,14 +1329,11 @@ class ChatPage extends LitElement { } initialChat(e) { - console.log('hello1', this.editor) if (this.editor && !this.editor.isFocused && this.currentEditor === '_chatEditorDOM') { - console.log('hello2') // WARNING: Deprecated methods from KeyBoard Event if (e.code === "Space" || e.keyCode === 32 || e.which === 32) { // this.chatEditor.insertText(' '); } else if (inputKeyCodes.includes(e.keyCode)) { - console.log('hello3') this.editor.commands.insertContent(e.key) // this.chatEditor.insertText(e.key); this.editor.commands.focus('end') @@ -1564,15 +1551,7 @@ class ChatPage extends LitElement { }).then(res => { this.balance = res }) - parentEpml.subscribe('frame_paste_menu_switch', async res => { - - res = JSON.parse(res) - if (res.isOpen === false && this.isPasteMenuOpen === true) { - - this.pasteToTextBox(textarea) - this.isPasteMenuOpen = false - } - }) + }) parentEpml.imReady(); @@ -1593,10 +1572,7 @@ class ChatPage extends LitElement { await this.initUpdate() } - if (changedProperties && changedProperties.has('openForwardOpen')) { - if (this.openForwardOpen === true) { - } - } + if (changedProperties && changedProperties.has('isLoading')) { if (this.isLoading === true && this.currentEditor === '_chatEditorDOM') { this.editor.setEditable(false) @@ -1979,12 +1955,7 @@ async getName (recipient) { // Message Event this.webSocket.onmessage = async (e) => { if (initial === 0) { - const isReceipient = this.chatId.includes('direct') - - // commented out code= localstorage persistance - // const chatReference1 = isReceipient ? 'direct' : 'group'; - // const chatReference2 = this.chatId.split('/')[1]; - // const cachedData = await messagesCache.getItem(`${chatReference1}-${chatReference2}`); + const cachedData = null let getInitialMessages = [] if (cachedData && cachedData.length !== 0) { @@ -2021,7 +1992,7 @@ async getName (recipient) { } // Error Event - this.webSocket.onerror = (e) => { + this.webSocket.onerror = () => { clearTimeout(directSocketTimeout) } @@ -2066,11 +2037,7 @@ async getName (recipient) { this.webSocket.onmessage = async (e) => { if (initial === 0) { - const isGroup = this.chatId.includes('group') - const chatReference1 = isGroup ? 'group' : 'direct'; - const chatReference2 = this.chatId.split('/')[1]; - - // const cachedData = await messagesCache.getItem(`${chatReference1}-${chatReference2}`); + const cachedData = null; let getInitialMessages = [] if (cachedData && cachedData.length !== 0) { @@ -2110,7 +2077,7 @@ async getName (recipient) { } // Error Event - this.webSocket.onerror = (e) => { + this.webSocket.onerror = () => { clearTimeout(groupSocketTimeout) } @@ -2652,7 +2619,7 @@ async getName (recipient) { let chatBytesArray = null; - await new Promise((res, rej) => { + await new Promise((res) => { worker.postMessage({chatBytes, path, difficulty}); worker.onmessage = e => { chatBytesArray = e.data.chatBytesArray; diff --git a/qortal-ui-plugins/plugins/core/components/ChatScroller-css.js b/qortal-ui-plugins/plugins/core/components/ChatScroller-css.js index fd3392c4..82f04c84 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatScroller-css.js +++ b/qortal-ui-plugins/plugins/core/components/ChatScroller-css.js @@ -196,6 +196,7 @@ export const chatStyles = css` overflow: hidden; text-overflow: ellipsis; max-width: 300px; + max-height: 40px; } .replied-message p { margin: 0px; diff --git a/qortal-ui-plugins/plugins/core/components/ChatScroller.js b/qortal-ui-plugins/plugins/core/components/ChatScroller.js index de34e742..61782610 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatScroller.js +++ b/qortal-ui-plugins/plugins/core/components/ChatScroller.js @@ -71,8 +71,6 @@ class ChatScroller extends LitElement { } render() { - console.log('this.messages', this.messages) - console.log(9, "chat scroller here"); let formattedMessages = this.messages.reduce((messageArray, message, index) => { const lastGroupedMessage = messageArray[messageArray.length - 1]; let timestamp; @@ -850,7 +848,6 @@ class ChatMenu extends LitElement { } render() { - console.log(this.messages, 'this.messages') return html`
60) { - scrollHeightBool = true; - } - } catch (error) { - scrollHeightBool = false; - } + return html`
-
@@ -530,44 +513,13 @@ class ChatTextEditor extends LitElement { } } - initialChat(e) { - // if (!this.chatEditor?.contentDiv.matches(':focus')) { - // // WARNING: Deprecated methods from KeyBoard Event - // if (e.code === "Space" || e.keyCode === 32 || e.which === 32) { - // this.chatEditor.insertText(' '); - // } else if (inputKeyCodes.includes(e.keyCode)) { - // this.chatEditor.insertText(e.key); - // return this.chatEditor.focus(); - // } else { - // return this.chatEditor.focus(); - // } - // } - } - - addGlobalEventListener(){ - document.addEventListener('keydown', this.initialChat); - } + - removeGlobalEventListener(){ - document.removeEventListener('keydown', this.initialChat); - } + async firstUpdated() { - if (this.hasGlobalEvents) { - // this.addGlobalEventListener(); - } - Image.configure({ - inline: true, - }) - // this.editor = new Editor({ - // element: this.shadowRoot.querySelector('.element'), - // extensions: [ - // StarterKit, - // Underline, - // Image - // ], - // content: '

Hello World!

', - // }) + + window.addEventListener('storage', () => { const checkTheme = localStorage.getItem('qortalTheme'); @@ -600,8 +552,7 @@ class ChatTextEditor extends LitElement { }); this.emojiPicker.on('emoji', selection => { - const emojiHtmlString = `${selection.emoji}`; - console.log('hello insert 6', selection) + this.editor.commands.insertContent(selection.emoji, { parseOptions: { preserveWhitespace: false @@ -652,7 +603,6 @@ class ChatTextEditor extends LitElement { } getMessageSize(message){ - console.log({message}) try { const trimmedMessage = message @@ -710,15 +660,6 @@ class ChatTextEditor extends LitElement { } - calculateIFrameHeight(height) { - setTimeout(()=> { - const editorTest = this.shadowRoot.getElementById(this.iframeId).contentWindow.document.getElementById('chatbarId').scrollHeight; - this.iframeHeight = editorTest + 20; - }, 50) - } - resetIFrameHeight(height) { - this.iframeHeight = 42; - } }