remove unsued code
This commit is contained in:
parent
efcfe649ca
commit
ddb91d2266
@ -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 {
|
||||
</div>
|
||||
<div style="display: flex; height: 100%; align-items: center">
|
||||
<vaadin-icon class="top-bar-icon" @click=${this._toggle} style="margin: 0px 10px" icon="vaadin:info" slot="icon"></vaadin-icon>
|
||||
<!-- <chat-group-settings .chatHeads=${this.chatHeads} .selectedAddress=${this.selectedAddress} .leaveGroupObj=${this.groupInfo} .setActiveChatHeadUrl=${(val)=> this.setActiveChatHeadUrl(val)}></chat-group-settings> -->
|
||||
<!-- <vaadin-icon class="top-bar-icon" style="margin: 0px 20px" icon="vaadin:search" slot="icon"></vaadin-icon> -->
|
||||
<!-- <vaadin-icon class="top-bar-icon" style="margin: 0px 20px" icon="vaadin:exit" slot="icon"></vaadin-icon> -->
|
||||
<!-- <chat-leave-group .chatHeads=${this.chatHeads} .selectedAddress=${this.selectedAddress} .leaveGroupObj=${this.groupInfo} .setActiveChatHeadUrl=${(val)=> this.setActiveChatHeadUrl(val)}></chat-leave-group> -->
|
||||
</div>
|
||||
</div>
|
||||
` : 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;
|
||||
|
@ -196,6 +196,7 @@ export const chatStyles = css`
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 300px;
|
||||
max-height: 40px;
|
||||
}
|
||||
.replied-message p {
|
||||
margin: 0px;
|
||||
|
@ -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`
|
||||
<div class="container">
|
||||
<div
|
||||
|
@ -1,13 +1,8 @@
|
||||
import { LitElement, html, css } from "lit";
|
||||
import { get } from 'lit-translate';
|
||||
import { escape, unescape } from 'html-escaper';
|
||||
|
||||
import { EmojiPicker } from 'emoji-picker-js';
|
||||
import { inputKeyCodes } from '../../utils/keyCodes.js';
|
||||
import { Epml } from '../../../epml.js';
|
||||
import { Editor } from '@tiptap/core'
|
||||
import StarterKit from '@tiptap/starter-kit'
|
||||
import Underline from '@tiptap/extension-underline';
|
||||
import Image from '@tiptap/extension-image'
|
||||
import '@material/mwc-icon'
|
||||
|
||||
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent });
|
||||
@ -340,6 +335,9 @@ class ChatTextEditor extends LitElement {
|
||||
white-space: nowrap;
|
||||
direction: ltr;
|
||||
}
|
||||
.hide-styling {
|
||||
display: none;
|
||||
}
|
||||
|
||||
`
|
||||
}
|
||||
@ -349,12 +347,7 @@ class ChatTextEditor extends LitElement {
|
||||
this.isLoadingMessages = true
|
||||
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)
|
||||
this.initialChat = this.initialChat.bind(this)
|
||||
this.iframeHeight = 42
|
||||
this.chatMessageSize = 0
|
||||
this.userName = window.parent.reduxStore.getState().app.accountInfo.names[0]
|
||||
@ -363,19 +356,10 @@ class ChatTextEditor extends LitElement {
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log('this.editor', this.chatMessageSize)
|
||||
let scrollHeightBool = false;
|
||||
try {
|
||||
console.log('this.chatMessageInput', this.chatMessageInput)
|
||||
if (this.chatMessageInput && this.chatMessageInput.scrollHeight > 60) {
|
||||
scrollHeightBool = true;
|
||||
}
|
||||
} catch (error) {
|
||||
scrollHeightBool = false;
|
||||
}
|
||||
|
||||
return html`
|
||||
<div
|
||||
class=${["chatbar-container", "chatbar-buttons"].join(" ")}
|
||||
class=${["chatbar-container", "chatbar-buttons", this.iframeId !=="_chatEditorDOM" && 'hide-styling'].join(" ")}
|
||||
style="align-items: center;">
|
||||
|
||||
<button
|
||||
@ -460,7 +444,6 @@ class ChatTextEditor extends LitElement {
|
||||
</div>
|
||||
</div>
|
||||
<textarea style="color: var(--black);" tabindex='1' ?autofocus=${true} ?disabled=${this.isLoading || this.isLoadingMessages} id="messageBox" rows="1"></textarea>
|
||||
<!-- <iframe style=${(this.iframeId === "newChat" && this.iframeHeight > 42) && "height: 100%;"} id=${this.iframeId} class="chat-editor" tabindex="-1" height=${this.iframeHeight}></iframe> -->
|
||||
<div id=${this.iframeId}
|
||||
class=${["element", this.iframeId === "privateMessage" ? "privateMessageMargin" : ""].join(" ")}
|
||||
></div>
|
||||
@ -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: '<p>Hello World!</p>',
|
||||
// })
|
||||
|
||||
|
||||
|
||||
window.addEventListener('storage', () => {
|
||||
const checkTheme = localStorage.getItem('qortalTheme');
|
||||
@ -600,8 +552,7 @@ class ChatTextEditor extends LitElement {
|
||||
});
|
||||
|
||||
this.emojiPicker.on('emoji', selection => {
|
||||
const emojiHtmlString = `<img class="emoji" draggable="false" alt="${selection.emoji}" src="${selection.url}">`;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user