diff --git a/qortal-ui-plugins/package.json b/qortal-ui-plugins/package.json index a891f694..7ab1011d 100644 --- a/qortal-ui-plugins/package.json +++ b/qortal-ui-plugins/package.json @@ -21,15 +21,16 @@ "@material/mwc-list": "0.27.0", "@material/mwc-select": "0.27.0", "@tiptap/core": "2.0.0-beta.209", + "@tiptap/extension-highlight": "2.0.0-beta.209", "@tiptap/extension-image": "2.0.0-beta.209", "@tiptap/extension-placeholder": "2.0.0-beta.209", "@tiptap/extension-underline": "2.0.0-beta.209", - "@tiptap/extension-highlight": "2.0.0-beta.209", "@tiptap/html": "2.0.0-beta.209", "@tiptap/starter-kit": "2.0.0-beta.209", "asmcrypto.js": "2.3.2", "compressorjs": "1.1.1", "emoji-picker-js": "https://github.com/Qortal/emoji-picker-js", + "localforage": "1.10.0", "prosemirror-commands": "1.5.0", "prosemirror-dropcursor": "1.6.1", "prosemirror-gapcursor": "1.3.1", @@ -40,7 +41,6 @@ "prosemirror-state": "1.4.2", "prosemirror-transform": "1.7.0", "prosemirror-view": "1.29.1", - "localforage": "1.10.0", "short-unique-id": "4.4.4" }, "devDependencies": { @@ -48,12 +48,12 @@ "@material/mwc-button": "0.27.0", "@material/mwc-checkbox": "0.27.0", "@material/mwc-dialog": "0.27.0", - "@material/mwc-fab": "0.27.0", "@material/mwc-formfield": "0.27.0", "@material/mwc-icon": "0.27.0", "@material/mwc-icon-button": "0.27.0", "@material/mwc-slider": "0.27.0", "@material/mwc-snackbar": "0.27.0", + "@material/mwc-fab": "0.27.0", "@material/mwc-tab": "0.27.0", "@material/mwc-tab-bar": "0.27.0", "@material/mwc-textfield": "0.27.0", @@ -84,9 +84,10 @@ "rollup": "3.10.1", "rollup-plugin-node-globals": "1.4.0", "rollup-plugin-progress": "1.1.2", - "rollup-plugin-web-worker-loader": "1.6.1" + "rollup-plugin-web-worker-loader": "1.6.1", + "passive-events-support": "1.0.33" }, "engines": { "node": ">=16.17.1" } -} \ No newline at end of file +} diff --git a/qortal-ui-plugins/plugins/core/components/ChatPage.js b/qortal-ui-plugins/plugins/core/components/ChatPage.js index fac3dc2b..91691e05 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatPage.js +++ b/qortal-ui-plugins/plugins/core/components/ChatPage.js @@ -103,7 +103,8 @@ class ChatPage extends LitElement { openUserInfo: { type: Boolean }, selectedHead: { type: Object }, userName: { type: String }, - goToRepliedMessage: {attribute: false} + goToRepliedMessage: {attribute: false}, + isLoadingGoToRepliedMessage: {type: Object} } } @@ -891,6 +892,12 @@ class ChatPage extends LitElement { this.currentEditor = '_chatEditorDOM' this.initialChat = this.initialChat.bind(this) this.isEnabledChatEnter = true + this.isLoadingGoToRepliedMessage = { + isLoading: false, + top: 0, + left: 0, + offsetHeight: 0 + } } _toggle(value) { @@ -941,7 +948,6 @@ class ChatPage extends LitElement { ` : null} -
${this.isLoadingMessages ? html` @@ -959,6 +965,9 @@ class ChatPage extends LitElement { ` : this.renderChatScroller()}
+ ${this.isLoadingGoToRepliedMessage && this.isLoadingGoToRepliedMessage.loading ? html` +
+ ` : ''}
{ @@ -1688,7 +1726,6 @@ class ChatPage extends LitElement { name: name ? name : undefined } } catch (error) { - console.log(error) } return memberItem @@ -1703,7 +1740,6 @@ class ChatPage extends LitElement { name: name ? name : undefined } } catch (error) { - console.log(error) } return memberItem @@ -1713,7 +1749,6 @@ class ChatPage extends LitElement { this.groupMembers = membersWithName this.groupInfo = getGroupInfo } catch (error) { - console.error(error) } } @@ -1748,7 +1783,7 @@ class ChatPage extends LitElement { if(isEnabledChatEnter){ this.isEnabledChatEnter = isEnabledChatEnter === 'false' ? false : true } - await this.initUpdate() + } async updated(changedProperties) { @@ -1760,16 +1795,13 @@ class ChatPage extends LitElement { } } - if (changedProperties && changedProperties.has('chatId') && changedProperties.get('chatId')) { - await this.initUpdate() - } if (changedProperties && changedProperties.has('isLoading')) { - if (this.isLoading === true && this.currentEditor === '_chatEditorDOM') { + if (this.isLoading === true && this.currentEditor === '_chatEditorDOM' && this.editor && this.editor.setEditable) { this.editor.setEditable(false) } - if (this.isLoading === false && this.currentEditor === '_chatEditorDOM') { + if (this.isLoading === false && this.currentEditor === '_chatEditorDOM' && this.editor && this.editor.setEditable) { this.editor.setEditable(true) } } @@ -1844,7 +1876,7 @@ class ChatPage extends LitElement { .setSelectedHead=${(val) => this.setSelectedHead(val)} ?openTipUser=${this.openTipUser} .selectedHead=${this.selectedHead} - .goToRepliedMessage=${(val)=> this.goToRepliedMessage(val)} + .goToRepliedMessage=${(val, val2)=> this.goToRepliedMessage(val, val2)} .getOldMessageAfter=${(val)=> this.getOldMessageAfter(val)} > @@ -2270,7 +2302,7 @@ class ChatPage extends LitElement { async fetchChatMessages(chatId) { - const initDirect = async (cid) => { + const initDirect = async (cid, noInitial) => { let initial = 0 let directSocketTimeout @@ -2290,17 +2322,15 @@ class ChatPage extends LitElement { } this.webSocket = new WebSocket(directSocketLink); - // Open Connection this.webSocket.onopen = () => { - setTimeout(pingDirectSocket, 50) } // Message Event this.webSocket.onmessage = async (e) => { if (initial === 0) { - + if(noInitial) return const cachedData = null let getInitialMessages = [] if (cachedData && cachedData.length !== 0) { @@ -2332,8 +2362,10 @@ class ChatPage extends LitElement { } // Closed Event - this.webSocket.onclose = () => { + this.webSocket.onclose = (e) => { clearTimeout(directSocketTimeout) + if(e.reason === 'switch chat') return + restartDirectWebSocket() } // Error Event @@ -2348,8 +2380,17 @@ class ChatPage extends LitElement { } }; + const restartDirectWebSocket = () => { + const noInitial = true + setTimeout(() => initDirect(chatId, noInitial), 50) + } + const restartGroupWebSocket = () => { + const noInitial = true + let groupChatId = Number(chatId) + setTimeout(() => initGroup(groupChatId, noInitial), 50) + } - const initGroup = (gId) => { + const initGroup = (gId, noInitial) => { let groupId = Number(gId) let initial = 0 @@ -2382,7 +2423,7 @@ class ChatPage extends LitElement { this.webSocket.onmessage = async (e) => { if (initial === 0) { - + if(noInitial) return const cachedData = null; let getInitialMessages = [] if (cachedData && cachedData.length !== 0) { @@ -2417,8 +2458,10 @@ class ChatPage extends LitElement { } // Closed Event - this.webSocket.onclose = () => { + this.webSocket.onclose = (e) => { clearTimeout(groupSocketTimeout) + if(e.reason === 'switch chat') return + restartGroupWebSocket() } // Error Event @@ -2482,7 +2525,6 @@ class ChatPage extends LitElement { this._publicKey.hasPubKey = false } } catch (error) { - console.error(error); } if(!hasPublicKey || !this._publicKey.hasPubKey){ diff --git a/qortal-ui-plugins/plugins/core/components/ChatScroller.js b/qortal-ui-plugins/plugins/core/components/ChatScroller.js index eddcb8b6..1337aef4 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatScroller.js +++ b/qortal-ui-plugins/plugins/core/components/ChatScroller.js @@ -384,7 +384,6 @@ class MessageTemplate extends LitElement { repliedToData = this.messageObj.repliedToData; isImageDeleted = parsedMessageObj.isImageDeleted; reactions = parsedMessageObj.reactions || []; - console.log(reactions, 'reactions here'); version = parsedMessageObj.version; isForwarded = parsedMessageObj.type === 'forward'; isEdited = parsedMessageObj.isEdited && true; @@ -474,7 +473,6 @@ class MessageTemplate extends LitElement { const parsedMsg = JSON.parse(repliedToData.decodedMessage); repliedToData.decodedMessage = parsedMsg; } catch (error) { - console.error(error); } } @@ -563,7 +561,7 @@ class MessageTemplate extends LitElement { ${repliedToData && html`
{ - this.goToRepliedMessage(repliedToData) + this.goToRepliedMessage(repliedToData, this.messageObj) }}>

{ - // clearTimeout(typingTimer); - // if (nameInput.value) { - // console.log("typing started!"); - // typingTimer = setTimeout(this.userSearch, doneTypingInterval); - // } - // }); - - const getDataFromURL = () => { - let tempUrl = document.location.href - let splitedUrl = decodeURI(tempUrl).split('?') - let urlData = splitedUrl[1] - if (urlData !== undefined) { - this.chatId = urlData - } - } + const runFunctionsAfterPageLoad = () => { // Functions to exec after render while waiting for page info... @@ -526,7 +511,6 @@ class Chat extends LitElement { } this.userFoundModalOpen = true; } catch (error) { - console.error(error); let err4string = get("chatpage.cchange35"); parentEpml.request('showSnackBar', `${err4string}`) } @@ -767,7 +751,6 @@ class Chat extends LitElement { }) this.groupInvites = pendingGroupInvites; } catch (error) { - console.error(error); let err4string = get("chatpage.cchange61"); parentEpml.request('showSnackBar', `${err4string}`) } @@ -876,9 +859,10 @@ class Chat extends LitElement { } setChatHeads(chatObj) { - - let groupList = chatObj.groups.map(group => group.groupId === 0 ? { groupId: group.groupId, url: `group/${group.groupId}`, groupName: "Qortal General Chat", timestamp: group.timestamp === undefined ? 2 : group.timestamp } : { ...group, timestamp: group.timestamp === undefined ? 1 : group.timestamp, url: `group/${group.groupId}` }) - let directList = chatObj.direct.map(dc => { + const chatObjGroups = Array.isArray(chatObj.groups) ? chatObj.groups : []; + const chatObjDirect = Array.isArray(chatObj.direct) ? chatObj.direct : []; + let groupList = chatObjGroups.map(group => group.groupId === 0 ? { groupId: group.groupId, url: `group/${group.groupId}`, groupName: "Qortal General Chat", timestamp: group.timestamp === undefined ? 2 : group.timestamp } : { ...group, timestamp: group.timestamp === undefined ? 1 : group.timestamp, url: `group/${group.groupId}` }) + let directList = chatObjDirect.map(dc => { return { ...dc, url: `direct/${dc.address}` } }) const compareNames = (a, b) => { diff --git a/qortal-ui-plugins/plugins/utils/replace-messages-edited.js b/qortal-ui-plugins/plugins/utils/replace-messages-edited.js index 7ee2cb06..b55e8848 100644 --- a/qortal-ui-plugins/plugins/utils/replace-messages-edited.js +++ b/qortal-ui-plugins/plugins/utils/replace-messages-edited.js @@ -21,7 +21,7 @@ export const replaceMessagesEdited = async ({ let responseItem = { ...response[0] } const decodeResponseItem = decodeMessageFunc(responseItem, isReceipient, _publicKey) delete decodeResponseItem.timestamp - console.log({msg}) + msgItem = { ...msg, ...decodeResponseItem, @@ -31,7 +31,6 @@ export const replaceMessagesEdited = async ({ } } } catch (error) { - console.log(error) } return msgItem @@ -42,7 +41,6 @@ export const replaceMessagesEdited = async ({ try { parsedMessageObj = JSON.parse(msg.decodedMessage) } catch (error) { - console.log('error') return msg } let msgItem = msg @@ -98,7 +96,6 @@ export const replaceMessagesEdited = async ({ } } } catch (error) { - console.log(error) } return msgItem