diff --git a/qortal-ui-core/src/notifications/notification-actions/new-message.js b/qortal-ui-core/src/notifications/notification-actions/new-message.js index faaaad32..f430fdd2 100644 --- a/qortal-ui-core/src/notifications/notification-actions/new-message.js +++ b/qortal-ui-core/src/notifications/notification-actions/new-message.js @@ -2,7 +2,6 @@ import { store } from '../../store.js' import { doPageUrl } from '../../redux/app/app-actions.js' export const newMessage = (data) => { - const alert = playSound(data.sound) // Should I show notification ? @@ -18,7 +17,7 @@ export const newMessage = (data) => { } notify.onclick = (e) => { - const pageUrl = `/app/q-chat/${data.req.url}` + const pageUrl = `/app/q-chat/?chat=${data.req.url}` store.dispatch(doPageUrl(pageUrl)) } } else { @@ -26,7 +25,7 @@ export const newMessage = (data) => { const notify = new Notification(data.title, data.options) notify.onclick = (e) => { - const pageUrl = `/app/q-chat/${data.req.url}` + const pageUrl = `/app/q-chat/?chat=${data.req.url}` store.dispatch(doPageUrl(pageUrl)) } } diff --git a/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js b/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js index a8b268e5..fbe12aa5 100644 --- a/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js +++ b/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js @@ -29,7 +29,7 @@ import StarterKit from '@tiptap/starter-kit' import Underline from '@tiptap/extension-underline'; import Placeholder from '@tiptap/extension-placeholder' import { Editor, Extension } from '@tiptap/core' - +import Highlight from '@tiptap/extension-highlight' const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) class Chat extends LitElement { @@ -55,7 +55,7 @@ class Chat extends LitElement { userFoundModalOpen: { type: Boolean }, userSelected: { type: Object }, editor: {type: Object}, - groupInvites: { type: Array } + groupInvites: { type: Array }, } } @@ -118,6 +118,7 @@ class Chat extends LitElement { } async connectedCallback() { + super.connectedCallback(); await this.getUpdateCompleteTextEditor(); @@ -147,15 +148,36 @@ class Chat extends LitElement { }}) ] }) + + this.unsubscribeStore = window.parent.reduxStore.subscribe(() => { + try { + + if(window.parent.location && window.parent.location.search){ + const queryString = window.parent.location.search; + const params = new URLSearchParams(queryString); + const chat = params.get("chat") + if(chat && chat !== this.activeChatHeadUrl){ + let url = window.parent.location.href; + let newUrl = url.split("?")[0]; + window.parent.history.pushState({}, "", newUrl); + this.setActiveChatHeadUrl(chat) + } + } + } catch (error) { + console.error(error) + } + + }); } disconnectedCallback() { super.disconnectedCallback(); - this.editor.destroy() - + this.editor.destroy(); + this.unsubscribeStore(); } + updatePlaceholder(editor, text){ editor.extensionManager.extensions.forEach((extension) => { if (extension.name === "placeholder") { @@ -215,7 +237,7 @@ class Chat extends LitElement {
- ${window.parent.location.pathname !== "/app/q-chat" || this.activeChatHeadUrl ? html`${this.renderChatPage(this.chatId)}` : html`${this.renderChatWelcomePage()}`} + ${this.activeChatHeadUrl ? html`${this.renderChatPage()}` : html`${this.renderChatWelcomePage()}`}
@@ -367,6 +389,8 @@ class Chat extends LitElement { ` } + + async firstUpdated() { this.changeLanguage(); this.changeTheme(); @@ -482,8 +506,11 @@ class Chat extends LitElement { }) }) parentEpml.imReady() + } + + setOpenPrivateMessage(props) { this.openPrivateMessage = props.open; this.shadowRoot.getElementById("sendTo").value = props.name @@ -839,7 +866,7 @@ class Chat extends LitElement { }) } - renderChatPage(chatId) { + renderChatPage() { // Check for the chat ID from and render chat messages // Else render Welcome to Q-CHat