Update q-chat and remove errors

This commit is contained in:
AlphaX-Projects 2023-07-27 17:31:16 +02:00
parent d0d5de5b47
commit 734e2a6ff5
29 changed files with 445 additions and 10030 deletions

View File

@ -5,12 +5,12 @@ import * as zip from '@zip.js/zip.js';
import '@material/mwc-icon'; import '@material/mwc-icon';
import ShortUniqueId from 'short-unique-id'; import ShortUniqueId from 'short-unique-id';
import {publishData} from '../../../utils/publish-image.js'; import {publishData} from '../../../utils/publish-image.js';
import {translate, get} from 'lit-translate';
import {gifExplorerStyles} from './ChatGifs-css.js'; import {gifExplorerStyles} from './ChatGifs-css.js';
import { bytesToMegabytes } from '../../../utils/bytesToMegabytes.js'; import { bytesToMegabytes } from '../../../utils/bytesToMegabytes.js';
import './ChatGifsExplore.js'; import './ChatGifsExplore.js';
import '../ImageComponent.js'; import '../ImageComponent.js';
import '@vaadin/tooltip'; import '@vaadin/tooltip';
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({type: 'WINDOW', source: window.parent}); const parentEpml = new Epml({type: 'WINDOW', source: window.parent});
@ -993,4 +993,4 @@ setOpenGifModal: { attribute: false }
} }
window.customElements.define('chat-gifs', ChatGifs); window.customElements.define('chat-gifs', ChatGifs)

View File

@ -1,8 +1,8 @@
import { LitElement, html, css } from 'lit'; import { LitElement, html, css } from 'lit'
import { Epml } from '../../../../epml.js'; import { Epml } from '../../../../epml.js'
import { chatGifsExploreStyles } from './ChatGifsExplore-css.js'; import { chatGifsExploreStyles } from './ChatGifsExplore-css.js'
import { translate, get } from 'lit-translate'; import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
import '@material/mwc-icon'; import '@material/mwc-icon'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }); const parentEpml = new Epml({ type: 'WINDOW', source: window.parent });
@ -69,9 +69,9 @@ class ChatGifsExplore extends LitElement {
this.elementObserver(); this.elementObserver();
} }
getApiKey() { getApiKey() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
let apiKey = myNode.apiKey; let apiKey = myNode.apiKey
return apiKey; return apiKey
} }
async searchCollections() { async searchCollections() {
@ -169,4 +169,4 @@ class ChatGifsExplore extends LitElement {
} }
window.customElements.define('chat-gifs-explore', ChatGifsExplore); window.customElements.define('chat-gifs-explore', ChatGifsExplore)

View File

@ -1,6 +1,5 @@
import { LitElement, html, css } from "lit" import { LitElement, html, css } from "lit"
import { render } from "lit/html.js" import { render } from "lit/html.js"
import { get, translate } from "lit-translate"
import { Epml } from "../../../epml" import { Epml } from "../../../epml"
import snackbar from "./snackbar.js" import snackbar from "./snackbar.js"
import "@material/mwc-button" import "@material/mwc-button"
@ -8,6 +7,7 @@ import "@material/mwc-dialog"
import "@polymer/paper-spinner/paper-spinner-lite.js" import "@polymer/paper-spinner/paper-spinner-lite.js"
import "@material/mwc-icon" import "@material/mwc-icon"
import "./WrapperModal" import "./WrapperModal"
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: "WINDOW", source: window.parent }) const parentEpml = new Epml({ type: "WINDOW", source: window.parent })

View File

@ -1,13 +1,13 @@
import { LitElement, html, css } from 'lit'; import { LitElement, html, css } from 'lit'
import { render } from 'lit/html.js'; import { render } from 'lit/html.js'
import { get, translate } from 'lit-translate'; import { Epml } from '../../../epml'
import { Epml } from '../../../epml';
import snackbar from './snackbar.js' import snackbar from './snackbar.js'
import '@material/mwc-button'; import '@material/mwc-button'
import '@material/mwc-dialog'; import '@material/mwc-dialog'
import '@polymer/paper-spinner/paper-spinner-lite.js' import '@polymer/paper-spinner/paper-spinner-lite.js'
import '@material/mwc-icon'; import '@material/mwc-icon'
import './WrapperModal'; import './WrapperModal'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
@ -25,7 +25,7 @@ class ChatGroupSettings extends LitElement {
} }
constructor() { constructor() {
super(); super()
this.isLoading = false; this.isLoading = false;
this.isOpenLeaveModal = false this.isOpenLeaveModal = false
this.leaveGroupObj = {} this.leaveGroupObj = {}

View File

@ -1,19 +1,19 @@
import { LitElement, html, css } from 'lit'; import { LitElement, html, css } from 'lit'
import { render } from 'lit/html.js'; import { render } from 'lit/html.js'
import { get, translate } from 'lit-translate'; import { Epml } from '../../../epml'
import { Epml } from '../../../epml';
import snackbar from './snackbar.js' import snackbar from './snackbar.js'
import '@material/mwc-button'; import '@material/mwc-button'
import '@material/mwc-dialog'; import '@material/mwc-dialog'
import '@polymer/paper-spinner/paper-spinner-lite.js' import '@polymer/paper-spinner/paper-spinner-lite.js'
import '@material/mwc-icon'; import '@material/mwc-icon'
import './WrapperModal'; import './WrapperModal'
import '@vaadin/tabs' import '@vaadin/tabs'
import '@vaadin/tabs/theme/material/vaadin-tabs.js'; import '@vaadin/tabs/theme/material/vaadin-tabs.js'
import '@vaadin/avatar'; import '@vaadin/avatar'
import '@vaadin/grid'; import '@vaadin/grid'
import '@vaadin/grid/vaadin-grid-filter-column.js'; import '@vaadin/grid/vaadin-grid-filter-column.js'
import { columnBodyRenderer } from '@vaadin/grid/lit.js'; import { columnBodyRenderer } from '@vaadin/grid/lit.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })

View File

@ -1,18 +1,20 @@
import { LitElement, html, css } from 'lit' import { LitElement, html, css } from 'lit'
import { render } from 'lit/html.js' import { render } from 'lit/html.js'
import { Epml } from '../../../epml.js' import { Epml } from '../../../epml.js'
import localForage from "localforage"; import localForage from "localforage"
import { translate} from 'lit-translate'; import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
import '@material/mwc-icon' import '@material/mwc-icon'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
const chatLastSeen = localForage.createInstance({ const chatLastSeen = localForage.createInstance({
name: "chat-last-seen", name: "chat-last-seen",
}); })
class ChatHead extends LitElement { class ChatHead extends LitElement {
static get properties() { static get properties() {
return { return {
theme: { type: String, reflect: true },
selectedAddress: { type: Object }, selectedAddress: { type: Object },
config: { type: Object }, config: { type: Object },
chatInfo: { type: Object }, chatInfo: { type: Object },
@ -53,10 +55,7 @@ class ChatHead extends LitElement {
color: var(--chat-group); color: var(--chat-group);
} }
.about { .about {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@ -109,12 +108,13 @@ class ChatHead extends LitElement {
this.imageFetches = 0 this.imageFetches = 0
this.lastReadMessageTimestamp = 0 this.lastReadMessageTimestamp = 0
this.loggedInAddress = window.parent.reduxStore.getState().app.selectedAddress.address this.loggedInAddress = window.parent.reduxStore.getState().app.selectedAddress.address
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'
} }
createImage(imageUrl) { createImage(imageUrl) {
const imageHTMLRes = new Image(); const imageHTMLRes = new Image()
imageHTMLRes.src = imageUrl; imageHTMLRes.src = imageUrl
imageHTMLRes.style= "width:40px; height:40px; float: left; border-radius:50%"; imageHTMLRes.style= "width:40px; height:40px; float: left; border-radius:50%"
imageHTMLRes.onclick= () => { imageHTMLRes.onclick= () => {
this.openDialogImage = true; this.openDialogImage = true;
} }
@ -124,29 +124,25 @@ class ChatHead extends LitElement {
imageHTMLRes.onerror = () => { imageHTMLRes.onerror = () => {
if (this.imageFetches < 4) { if (this.imageFetches < 4) {
setTimeout(() => { setTimeout(() => {
this.imageFetches = this.imageFetches + 1; this.imageFetches = this.imageFetches + 1
imageHTMLRes.src = imageUrl; imageHTMLRes.src = imageUrl
}, 750); }, 750)
} else { } else {
this.isImageLoaded = false this.isImageLoaded = false
} }
}; };
return imageHTMLRes; return imageHTMLRes
} }
render() { render() {
let avatarImg = ''; let avatarImg = ''
let backupAvatarImg = '' let backupAvatarImg = ''
let isUnread = false let isUnread = false
if(this.chatInfo.name){ if(this.chatInfo.name){
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port; const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
const avatarUrl = `${nodeUrl}/arbitrary/THUMBNAIL/${this.chatInfo.name}/qortal_avatar?async=true&apiKey=${myNode.apiKey}`; const avatarUrl = `${nodeUrl}/arbitrary/THUMBNAIL/${this.chatInfo.name}/qortal_avatar?async=true&apiKey=${myNode.apiKey}`
avatarImg= this.createImage(avatarUrl) avatarImg= this.createImage(avatarUrl)
} }
@ -189,6 +185,19 @@ class ChatHead extends LitElement {
} }
async firstUpdated() { async firstUpdated() {
this.changeTheme()
window.addEventListener('storage', () => {
const checkTheme = localStorage.getItem('qortalTheme')
if (checkTheme === 'dark') {
this.theme = 'dark'
} else {
this.theme = 'light'
}
document.querySelector('html').setAttribute('theme', this.theme)
})
let configLoaded = false let configLoaded = false
this.lastReadMessageTimestamp = await chatLastSeen.getItem(this.chatInfo.url) || 0 this.lastReadMessageTimestamp = await chatLastSeen.getItem(this.chatInfo.url) || 0
parentEpml.ready().then(() => { parentEpml.ready().then(() => {
@ -217,6 +226,16 @@ class ChatHead extends LitElement {
parentEpml.imReady() parentEpml.imReady()
} }
changeTheme() {
const checkTheme = localStorage.getItem('qortalTheme')
if (checkTheme === 'dark') {
this.theme = 'dark'
} else {
this.theme = 'light'
}
document.querySelector('html').setAttribute('theme', this.theme)
}
shouldUpdate(changedProperties) { shouldUpdate(changedProperties) {
if(changedProperties.has('activeChatHeadUrl')){ if(changedProperties.has('activeChatHeadUrl')){
return true return true

View File

@ -1,13 +1,14 @@
import { LitElement, html, css } from 'lit'; import { LitElement, html, css } from 'lit'
import { render } from 'lit/html.js'; import { render } from 'lit/html.js'
import { get, translate } from 'lit-translate'; import { Epml } from '../../../epml'
import { Epml } from '../../../epml';
import snackbar from './snackbar.js' import snackbar from './snackbar.js'
import '@material/mwc-button'; import '@material/mwc-button'
import '@material/mwc-dialog'; import '@material/mwc-dialog'
import '@polymer/paper-spinner/paper-spinner-lite.js' import '@polymer/paper-spinner/paper-spinner-lite.js'
import '@material/mwc-icon'; import '@material/mwc-icon'
import './WrapperModal'; import './WrapperModal'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
class ChatLeaveGroup extends LitElement { class ChatLeaveGroup extends LitElement {

View File

@ -1,7 +1,7 @@
import { LitElement, html, css } from 'lit' import { LitElement, html, css } from 'lit'
import { render } from 'lit/html.js' import { render } from 'lit/html.js'
import { Epml } from '../../../epml.js' import { Epml } from '../../../epml.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })

View File

@ -1,10 +1,10 @@
import { LitElement, html, css } from 'lit'; import { LitElement, html, css } from 'lit'
import { render } from 'lit/html.js'; import { render } from 'lit/html.js'
import { get, translate } from 'lit-translate'; import { Epml } from '../../../epml'
import { Epml } from '../../../epml';
import snackbar from './snackbar.js' import snackbar from './snackbar.js'
import '@material/mwc-button'; import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
import '@material/mwc-dialog'; import '@material/mwc-button'
import '@material/mwc-dialog'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
@ -18,15 +18,15 @@ class ChatModals extends LitElement {
hidePrivateMessageModal: {type: Function}, hidePrivateMessageModal: {type: Function},
hideBlockUserModal: {type: Function}, hideBlockUserModal: {type: Function},
toblockaddress: { type: String, attribute: true }, toblockaddress: { type: String, attribute: true },
chatBlockedAdresses: { type: Array }, chatBlockedAdresses: { type: Array }
} }
} }
constructor() { constructor() {
super(); super()
this.isLoading = false; this.isLoading = false
this.hidePrivateMessageModal = () => {}; this.hidePrivateMessageModal = () => {}
this.hideBlockUserModal = () => {}; this.hideBlockUserModal = () => {}
this.chatBlockedAdresses = [] this.chatBlockedAdresses = []
} }
@ -105,13 +105,13 @@ class ChatModals extends LitElement {
} else { } else {
this.sendMessage() this.sendMessage()
} }
}; }
async sendMessage() { async sendMessage() {
this.isLoading = true; this.isLoading = true
const _recipient = this.shadowRoot.getElementById('sendTo').value; const _recipient = this.shadowRoot.getElementById('sendTo').value
const messageBox = this.shadowRoot.getElementById('messageBox'); const messageBox = this.shadowRoot.getElementById('messageBox')
const messageText = messageBox.value; const messageText = messageBox.value
let recipient; let recipient;
const validateName = async (receiverName) => { const validateName = async (receiverName) => {
@ -127,7 +127,7 @@ class ChatModals extends LitElement {
myRes = myNameRes myRes = myNameRes
} }
return myRes; return myRes
} }
const myNameRes = await validateName(_recipient) const myNameRes = await validateName(_recipient)
@ -138,8 +138,8 @@ class ChatModals extends LitElement {
recipient = myNameRes.owner recipient = myNameRes.owner
} }
let _reference = new Uint8Array(64); let _reference = new Uint8Array(64)
window.crypto.getRandomValues(_reference); window.crypto.getRandomValues(_reference)
let sendTimestamp = Date.now() let sendTimestamp = Date.now()
@ -200,17 +200,17 @@ class ChatModals extends LitElement {
const _computePow = async (chatBytes) => { const _computePow = async (chatBytes) => {
const _chatBytesArray = Object.keys(chatBytes).map(function (key) { return chatBytes[key]; }); const _chatBytesArray = Object.keys(chatBytes).map(function (key) { return chatBytes[key]; })
const chatBytesArray = new Uint8Array(_chatBytesArray) const chatBytesArray = new Uint8Array(_chatBytesArray)
const chatBytesHash = new window.parent.Sha256().process(chatBytesArray).finish().result const chatBytesHash = new window.parent.Sha256().process(chatBytesArray).finish().result
const hashPtr = window.parent.sbrk(32, window.parent.heap); const hashPtr = window.parent.sbrk(32, window.parent.heap)
const hashAry = new Uint8Array(window.parent.memory.buffer, hashPtr, 32); const hashAry = new Uint8Array(window.parent.memory.buffer, hashPtr, 32)
hashAry.set(chatBytesHash); hashAry.set(chatBytesHash)
const difficulty = this.balance < 4 ? 18 : 8; const difficulty = this.balance < 4 ? 18 : 8
const workBufferLength = 8 * 1024 * 1024; const workBufferLength = 8 * 1024 * 1024;
const workBufferPtr = window.parent.sbrk(workBufferLength, window.parent.heap); const workBufferPtr = window.parent.sbrk(workBufferLength, window.parent.heap)
let nonce = window.parent.computePow(hashPtr, workBufferPtr, workBufferLength, difficulty) let nonce = window.parent.computePow(hashPtr, workBufferPtr, workBufferLength, difficulty)
@ -250,9 +250,9 @@ class ChatModals extends LitElement {
} }
getApiKey() { getApiKey() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
let apiKey = myNode.apiKey; let apiKey = myNode.apiKey
return apiKey; return apiKey
} }
getChatBlockedList() { getChatBlockedList() {
@ -263,7 +263,7 @@ class ChatModals extends LitElement {
localStorage.removeItem("ChatBlockedAddresses") localStorage.removeItem("ChatBlockedAddresses")
var obj = []; var obj = []
fetch(blockedAddressesUrl).then(response => { fetch(blockedAddressesUrl).then(response => {
return response.json() return response.json()
@ -412,4 +412,4 @@ class ChatModals extends LitElement {
} }
} }
customElements.define('chat-modals', ChatModals); customElements.define('chat-modals', ChatModals)

View File

@ -35,7 +35,7 @@ import './ChatSideNavHeads.js'
import './ChatLeaveGroup.js' import './ChatLeaveGroup.js'
import './ChatGroupSettings.js' import './ChatGroupSettings.js'
import './ChatRightPanel.js' import './ChatRightPanel.js'
import './ChatSeachResults.js' import './ChatSearchResults.js'
import './ChatGifs/ChatGifs.js' import './ChatGifs/ChatGifs.js'
import '@material/mwc-button' import '@material/mwc-button'
@ -44,10 +44,6 @@ import '@material/mwc-icon'
import '@polymer/paper-dialog/paper-dialog.js' import '@polymer/paper-dialog/paper-dialog.js'
import '@polymer/paper-spinner/paper-spinner-lite.js' import '@polymer/paper-spinner/paper-spinner-lite.js'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
const chatLastSeen = localForage.createInstance({ const chatLastSeen = localForage.createInstance({
name: "chat-last-seen", name: "chat-last-seen",
}) })
@ -57,6 +53,7 @@ const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
class ChatPage extends LitElement { class ChatPage extends LitElement {
static get properties() { static get properties() {
return { return {
theme: { type: String, reflect: true },
selectedAddress: { type: Object }, selectedAddress: { type: Object },
config: { type: Object }, config: { type: Object },
messages: { type: Array }, messages: { type: Array },
@ -1350,6 +1347,7 @@ class ChatPage extends LitElement {
left: 0, left: 0,
offsetHeight: 0 offsetHeight: 0
} }
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'
} }
setOpenGifModal(value) { setOpenGifModal(value) {
@ -2377,10 +2375,20 @@ class ChatPage extends LitElement {
} }
async firstUpdated() { async firstUpdated() {
this.changeTheme()
window.addEventListener('storage', () => { window.addEventListener('storage', () => {
const checkLanguage = localStorage.getItem('qortalLanguage') const checkLanguage = localStorage.getItem('qortalLanguage')
use(checkLanguage) const checkTheme = localStorage.getItem('qortalTheme')
this.userLanguage = checkLanguage this.userLanguage = checkLanguage
if (checkTheme === 'dark') {
this.theme = 'dark'
} else {
this.theme = 'light'
}
document.querySelector('html').setAttribute('theme', this.theme)
}) })
parentEpml.ready().then(() => { parentEpml.ready().then(() => {
@ -2406,6 +2414,16 @@ class ChatPage extends LitElement {
} }
changeTheme() {
const checkTheme = localStorage.getItem('qortalTheme')
if (checkTheme === 'dark') {
this.theme = 'dark'
} else {
this.theme = 'light'
}
document.querySelector('html').setAttribute('theme', this.theme)
}
async updated(changedProperties) { async updated(changedProperties) {
if (changedProperties && changedProperties.has('userLanguage')) { if (changedProperties && changedProperties.has('userLanguage')) {
const userLang = changedProperties.get('userLanguage') const userLang = changedProperties.get('userLanguage')
@ -3926,7 +3944,6 @@ class ChatPage extends LitElement {
} }
pasteToTextBox(textarea) { pasteToTextBox(textarea) {
// Return focus to the window // Return focus to the window
window.focus() window.focus()

View File

@ -1,6 +1,5 @@
import { LitElement, html, css } from "lit"; import { LitElement, html, css } from "lit";
import { render } from "lit/html.js"; import { render } from "lit/html.js";
import { get, translate } from "lit-translate";
import { Epml } from "../../../epml"; import { Epml } from "../../../epml";
import { getUserNameFromAddress } from "../../utils/getUserNameFromAddress"; import { getUserNameFromAddress } from "../../utils/getUserNameFromAddress";
import snackbar from "./snackbar.js"; import snackbar from "./snackbar.js";
@ -13,6 +12,9 @@ import '@vaadin/button';
import "./WrapperModal"; import "./WrapperModal";
import "./TipUser" import "./TipUser"
import "./UserInfo/UserInfo"; import "./UserInfo/UserInfo";
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
class ChatRightPanel extends LitElement { class ChatRightPanel extends LitElement {
static get properties() { static get properties() {

View File

@ -29,10 +29,6 @@ import '@vaadin/icon'
import '@vaadin/icons' import '@vaadin/icons'
import '@vaadin/tooltip' import '@vaadin/tooltip'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
let toggledMessage = {} let toggledMessage = {}
@ -172,6 +168,7 @@ function processText(input) {
class ChatScroller extends LitElement { class ChatScroller extends LitElement {
static get properties() { static get properties() {
return { return {
theme: { type: String, reflect: true },
getNewMessage: { attribute: false }, getNewMessage: { attribute: false },
getOldMessage: { attribute: false }, getOldMessage: { attribute: false },
escapeHTML: { attribute: false }, escapeHTML: { attribute: false },
@ -216,6 +213,7 @@ class ChatScroller extends LitElement {
this.openTipUser = false this.openTipUser = false
this.openUserInfo = false this.openUserInfo = false
this.listSeenMessages = [] this.listSeenMessages = []
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'
} }
addSeenMessage(val) { addSeenMessage(val) {
@ -259,7 +257,6 @@ class ChatScroller extends LitElement {
return messageArray return messageArray
}, []) }, [])
return html` return html`
${this.isLoadingMessages ? html` ${this.isLoadingMessages ? html`
<div class="spinnerContainer"> <div class="spinnerContainer">
@ -337,8 +334,20 @@ class ChatScroller extends LitElement {
} }
async firstUpdated() { async firstUpdated() {
this.emojiPicker.on('emoji', selection => { this.changeTheme()
window.addEventListener('storage', () => {
const checkTheme = localStorage.getItem('qortalTheme')
if (checkTheme === 'dark') {
this.theme = 'dark'
} else {
this.theme = 'light'
}
document.querySelector('html').setAttribute('theme', this.theme)
})
this.emojiPicker.on('emoji', selection => {
this.sendMessage({ this.sendMessage({
type: 'reaction', type: 'reaction',
editedMessageObj: toggledMessage, editedMessageObj: toggledMessage,
@ -355,6 +364,16 @@ class ChatScroller extends LitElement {
this.viewElement.scrollTop = this.viewElement.scrollHeight + 50 this.viewElement.scrollTop = this.viewElement.scrollHeight + 50
} }
changeTheme() {
const checkTheme = localStorage.getItem('qortalTheme')
if (checkTheme === 'dark') {
this.theme = 'dark'
} else {
this.theme = 'light'
}
document.querySelector('html').setAttribute('theme', this.theme)
}
_getOldMessage(_scrollElement) { _getOldMessage(_scrollElement) {
this.getOldMessage(_scrollElement) this.getOldMessage(_scrollElement)
} }
@ -447,7 +466,7 @@ class MessageTemplate extends LitElement {
goToRepliedMessage: { attribute: false }, goToRepliedMessage: { attribute: false },
listSeenMessages: { type: Array }, listSeenMessages: { type: Array },
addSeenMessage: { attribute: false }, addSeenMessage: { attribute: false },
chatId: { type: String }, chatId: { type: String }
} }
} }
@ -1220,7 +1239,7 @@ class ChatMenu extends LitElement {
setOpenPrivateMessage: { attribute: false }, setOpenPrivateMessage: { attribute: false },
setOpenTipUser: { attribute: false }, setOpenTipUser: { attribute: false },
setUserName: { attribute: false }, setUserName: { attribute: false },
gif: { type: Boolean }, gif: { type: Boolean }
} }
} }

View File

@ -0,0 +1,72 @@
import { LitElement, html } from 'lit'
import { render } from 'lit/html.js'
import { Epml } from '../../../epml.js'
import { chatSearchResultsStyles } from './ChatSearchResults-css.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
import '@vaadin/icon'
import '@vaadin/icons'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
export class ChatSearchResults extends LitElement {
static get properties() {
return {
onClickFunc: { attribute: false },
closeFunc: { attribute: false },
searchResults: { type: Array },
isOpen: { type: Boolean },
loading: { type: Boolean }
}
}
static styles = [chatSearchResultsStyles]
render() {
return html`
<div class="chat-results-card" style=${this.isOpen ? "display: block;" : "display: none;"}>
<vaadin-icon
@click=${() => this.closeFunc()}
icon="vaadin:close-small"
slot="icon"
class="close-icon"
>
</vaadin-icon>
${this.loading ? (
html`
<div class="spinner-container">
<paper-spinner-lite active></paper-spinner-lite>
</div>
`
) : (
html`
<p class="chat-result-header">${translate("chatpage.cchange36")}</p>
<div class="divider"></div>
<div class="chat-result-container">
${this.searchResults.length === 0 ? (
html`<p class="no-results">${translate("chatpage.cchange37")}</p>`
) : (
html`
${this.searchResults.map((result) => {
return (
html`
<div class="chat-result-card" @click=${() => {
this.shadowRoot.querySelector(".chat-result-card").classList.add("active");
this.onClickFunc(result);
}}>
<p class="chat-result">
${result.name}
</p>
</div>
`
)}
)}
`
)}
</div>
`
)}
</div>
`
}
}
customElements.define('chat-search-results', ChatSearchResults)

View File

@ -1,4 +1,5 @@
import { LitElement, html, css } from 'lit' import { LitElement, html, css } from 'lit'
import { render } from 'lit/html.js'
import { Epml } from '../../../epml.js' import { Epml } from '../../../epml.js'
import '@material/mwc-icon' import '@material/mwc-icon'

View File

@ -1,6 +1,7 @@
import { LitElement, html, css } from 'lit' import { LitElement, html, css } from 'lit'
import { render } from 'lit/html.js'
import { Epml } from '../../../epml.js' import { Epml } from '../../../epml.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
import '@material/mwc-icon' import '@material/mwc-icon'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })

View File

@ -1,11 +1,12 @@
import { LitElement, html, css } from "lit"; import { LitElement, html, css } from "lit"
import { get } from 'lit-translate'; import { escape, unescape } from 'html-escaper'
import { escape, unescape } from 'html-escaper'; import { EmojiPicker } from 'emoji-picker-js'
import { EmojiPicker } from 'emoji-picker-js'; import { inputKeyCodes } from '../../utils/keyCodes.js'
import { inputKeyCodes } from '../../utils/keyCodes.js'; import { Epml } from '../../../epml.js'
import { Epml } from '../../../epml.js'; import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent });
class ChatTextEditor extends LitElement { class ChatTextEditor extends LitElement {
static get properties() { static get properties() {
return { return {
@ -298,13 +299,13 @@ class ChatTextEditor extends LitElement {
} }
window.addEventListener('storage', () => { window.addEventListener('storage', () => {
const checkTheme = localStorage.getItem('qortalTheme'); const checkTheme = localStorage.getItem('qortalTheme')
const chatbar = this.shadowRoot.getElementById(this.iframeId).contentWindow.document.getElementById('chatbarId'); const chatbar = this.shadowRoot.getElementById(this.iframeId).contentWindow.document.getElementById('chatbarId')
if (checkTheme === 'dark') { if (checkTheme === 'dark') {
this.theme = 'dark'; this.theme = 'dark'
chatbar.style.cssText = "color:#ffffff;" chatbar.style.cssText = "color:#ffffff;"
} else { } else {
this.theme = 'light'; this.theme = 'light'
chatbar.style.cssText = "color:#080808;" chatbar.style.cssText = "color:#080808;"
} }
}) })
@ -323,18 +324,18 @@ class ChatTextEditor extends LitElement {
boxShadow: 'rgba(4, 4, 5, 0.15) 0px 0px 0px 1px, rgba(0, 0, 0, 0.24) 0px 8px 16px 0px', boxShadow: 'rgba(4, 4, 5, 0.15) 0px 0px 0px 1px, rgba(0, 0, 0, 0.24) 0px 8px 16px 0px',
zIndex: 100 zIndex: 100
}); })
this.emojiPicker.on('emoji', selection => { this.emojiPicker.on('emoji', selection => {
const emojiHtmlString = `<img class="emoji" draggable="false" alt="${selection.emoji}" src="${selection.url}">`; const emojiHtmlString = `<img class="emoji" draggable="false" alt="${selection.emoji}" src="${selection.url}">`
this.chatEditor.insertEmoji(emojiHtmlString); this.chatEditor.insertEmoji(emojiHtmlString);
}); })
this.emojiPickerHandler.addEventListener('click', () => this.emojiPicker.togglePicker(this.emojiPickerHandler)); this.emojiPickerHandler.addEventListener('click', () => this.emojiPicker.togglePicker(this.emojiPickerHandler))
await this.updateComplete; await this.updateComplete
this.initChatEditor(); this.initChatEditor()
} }
async updated(changedProperties) { async updated(changedProperties) {
@ -348,12 +349,12 @@ class ChatTextEditor extends LitElement {
} }
} }
if (changedProperties && changedProperties.has('placeholder')) { if (changedProperties && changedProperties.has('placeholder')) {
const captionEditor = this.shadowRoot.getElementById(this.iframeId).contentWindow.document.getElementById('chatbarId'); const captionEditor = this.shadowRoot.getElementById(this.iframeId).contentWindow.document.getElementById('chatbarId')
captionEditor.setAttribute('data-placeholder', this.placeholder); captionEditor.setAttribute('data-placeholder', this.placeholder)
} }
if (changedProperties && changedProperties.has("imageFile")) { if (changedProperties && changedProperties.has("imageFile")) {
this.chatMessageInput = "newChat"; this.chatMessageInput = "newChat"
} }
} }
@ -365,12 +366,12 @@ class ChatTextEditor extends LitElement {
sendMessageFunc(props) { sendMessageFunc(props) {
if (this.chatMessageSize > 1000 ) { if (this.chatMessageSize > 1000 ) {
parentEpml.request('showSnackBar', get("chatpage.cchange29")); parentEpml.request('showSnackBar', get("chatpage.cchange29"))
return; return
}; };
this.chatMessageSize = 0; this.chatMessageSize = 0
this.chatEditor.updateMirror(); this.chatEditor.updateMirror()
this._sendMessage(props); this._sendMessage(props)
} }
getMessageSize(message){ getMessageSize(message){

View File

@ -1,13 +1,13 @@
import { LitElement, html, css } from "lit"; import { LitElement, html, css } from "lit";
import { get, translate } from 'lit-translate'; import { render } from 'lit/html.js'
import { EmojiPicker } from 'emoji-picker-js'
import { EmojiPicker } from 'emoji-picker-js'; import { Epml } from '../../../epml.js'
import { Epml } from '../../../epml.js';
import '@material/mwc-icon' import '@material/mwc-icon'
import '@material/mwc-checkbox' import '@material/mwc-checkbox'
// import { addAutoLoadImageChat } from "../../../../qortal-ui-core/src/redux/app/app-actions.js"; import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent });
class ChatTextEditor extends LitElement { class ChatTextEditor extends LitElement {
static get properties() { static get properties() {
return { return {
@ -589,11 +589,11 @@ mwc-checkbox::shadow .mdc-checkbox::after, mwc-checkbox::shadow .mdc-checkbox::b
const checkTheme = localStorage.getItem('qortalTheme'); const checkTheme = localStorage.getItem('qortalTheme');
const chatbar = this.shadowRoot.querySelector('.element') const chatbar = this.shadowRoot.querySelector('.element')
if (checkTheme === 'dark') { if (checkTheme === 'dark') {
this.theme = 'dark'; this.theme = 'dark'
chatbar.style.cssText = "color:#ffffff;" chatbar.style.cssText = "color:#ffffff;"
} else { } else {
this.theme = 'light'; this.theme = 'light'
chatbar.style.cssText = "color:#080808;" chatbar.style.cssText = "color:#080808;"
} }

View File

@ -3,16 +3,16 @@ import { render } from 'lit/html.js'
import { Epml } from '../../../epml.js' import { Epml } from '../../../epml.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate' import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
import '@material/mwc-icon' import '@material/mwc-icon'
import '@material/mwc-button' import '@material/mwc-button'
import '@material/mwc-dialog' import '@material/mwc-dialog'
import '@polymer/paper-spinner/paper-spinner-lite.js' import '@polymer/paper-spinner/paper-spinner-lite.js'
import '@vaadin/grid' import '@vaadin/grid'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
class ChatWelcomePage extends LitElement { class ChatWelcomePage extends LitElement {
@ -258,10 +258,16 @@ class ChatWelcomePage extends LitElement {
firstUpdated() { firstUpdated() {
this.changeTheme() this.changeTheme()
this.changeLanguage()
this.clearConsole()
setInterval(() => {
this.clearConsole()
}, 60000)
const stopKeyEventPropagation = (e) => { const stopKeyEventPropagation = (e) => {
e.stopPropagation(); e.stopPropagation()
return false; return false
} }
this.shadowRoot.getElementById('sendTo').addEventListener('keydown', stopKeyEventPropagation); this.shadowRoot.getElementById('sendTo').addEventListener('keydown', stopKeyEventPropagation);
@ -290,8 +296,6 @@ class ChatWelcomePage extends LitElement {
document.querySelector('html').setAttribute('theme', this.theme) document.querySelector('html').setAttribute('theme', this.theme)
}) })
let configLoaded = false
parentEpml.ready().then(() => { parentEpml.ready().then(() => {
parentEpml.subscribe('selected_address', async selectedAddress => { parentEpml.subscribe('selected_address', async selectedAddress => {
this.selectedAddress = {} this.selectedAddress = {}
@ -309,19 +313,22 @@ class ChatWelcomePage extends LitElement {
parentEpml.imReady() parentEpml.imReady()
} }
clearConsole() {
console.clear()
}
changeTheme() { changeTheme() {
const checkTheme = localStorage.getItem('qortalTheme') const checkTheme = localStorage.getItem('qortalTheme')
if (checkTheme === 'dark') { if (checkTheme === 'dark') {
this.theme = 'dark'; this.theme = 'dark'
} else { } else {
this.theme = 'light'; this.theme = 'light'
} }
document.querySelector('html').setAttribute('theme', this.theme); document.querySelector('html').setAttribute('theme', this.theme)
} }
changeLanguage() { changeLanguage() {
const checkLanguage = localStorage.getItem('qortalLanguage') const checkLanguage = localStorage.getItem('qortalLanguage')
if (checkLanguage === null || checkLanguage.length === 0) { if (checkLanguage === null || checkLanguage.length === 0) {
localStorage.setItem('qortalLanguage', 'us') localStorage.setItem('qortalLanguage', 'us')
use('us') use('us')
@ -343,7 +350,7 @@ class ChatWelcomePage extends LitElement {
} else { } else {
this.sendMessage(); this.sendMessage();
} }
}; }
async sendMessage() { async sendMessage() {
this.isLoading = true; this.isLoading = true;

View File

@ -1,6 +1,6 @@
import { LitElement, html, css } from 'lit'; import { LitElement, html, css } from 'lit'
import { translate, get } from 'lit-translate'; import { render } from 'lit/html.js'
import { render } from 'lit/html.js'; import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
export class ImageComponent extends LitElement { export class ImageComponent extends LitElement {
@ -48,52 +48,51 @@ border: 1px solid var(--mdc-theme-primary );
} }
constructor() { constructor() {
super(); super()
this.attempts = 0; this.attempts = 0
this.maxAttempts = 5; this.maxAttempts = 5
} }
getApiKey() { getApiKey() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
let apiKey = myNode.apiKey; let apiKey = myNode.apiKey
return apiKey; return apiKey
} }
async _fetchImage() { async _fetchImage() {
this.attempts++; this.attempts++;
if (this.attempts > this.maxAttempts) return; if (this.attempts > this.maxAttempts) return
await new Promise((res) => { await new Promise((res) => {
setTimeout(() => { setTimeout(() => {
res(); res()
}, 1000) }, 1000)
}); })
try { try {
const response = await fetch(this.gif.url); const response = await fetch(this.gif.url)
const data = await response.json(); const data = await response.json()
console.log({data});
if (data.ok) { if (data.ok) {
this.error = false; this.error = false
this.gif = { this.gif = {
...this.gif, ...this.gif,
url: data.src url: data.src
}; };
this.requestUpdate(); this.requestUpdate();
} else if (!data.ok || data.error) { } else if (!data.ok || data.error) {
this.error = true; this.error = true
} else { } else {
this.error = false; this.error = false
} }
} catch (error) { } catch (error) {
this.error = true; this.error = true
console.error(error); console.error(error)
this._fetchImage(); this._fetchImage()
} }
} }
render() { render() {
if (this.error && this.attempts <= this.maxAttempts) { if (this.error && this.attempts <= this.maxAttempts) {
setTimeout(() => { setTimeout(() => {
this._fetchImage(); this._fetchImage()
}, 1000); }, 1000)
} }
return html` return html`
${this.gif && !this.error ${this.gif && !this.error
@ -124,4 +123,4 @@ alt=${this.alt}
} }
} }
customElements.define('image-component', ImageComponent); customElements.define('image-component', ImageComponent)

View File

@ -3,11 +3,6 @@ import { render } from 'lit/html.js'
import { Epml } from '../../../epml.js' import { Epml } from '../../../epml.js'
import snackbar from './snackbar.js' import snackbar from './snackbar.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate' import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
import '@polymer/paper-tooltip/paper-tooltip.js' import '@polymer/paper-tooltip/paper-tooltip.js'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
@ -15,8 +10,8 @@ const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
class LevelFounder extends LitElement { class LevelFounder extends LitElement {
static get properties() { static get properties() {
return { return {
checkleveladdress: { type: String, attribute: true }, checkleveladdress: { type: String },
selectedAddress: { type: Object }, selectedAddress: { type: String },
config: { type: Object }, config: { type: Object },
memberInfo: { type: Array } memberInfo: { type: Array }
} }
@ -106,16 +101,8 @@ class LevelFounder extends LitElement {
} }
firstUpdated() { firstUpdated() {
this.changeLanguage()
this.checkAddressInfo() this.checkAddressInfo()
window.addEventListener('storage', () => {
const checkLanguage = localStorage.getItem('qortalLanguage')
use(checkLanguage)
})
let configLoaded = false
parentEpml.ready().then(() => { parentEpml.ready().then(() => {
parentEpml.subscribe('selected_address', async selectedAddress => { parentEpml.subscribe('selected_address', async selectedAddress => {
this.selectedAddress = {} this.selectedAddress = {}
@ -127,17 +114,6 @@ class LevelFounder extends LitElement {
parentEpml.imReady() parentEpml.imReady()
} }
changeLanguage() {
const checkLanguage = localStorage.getItem('qortalLanguage')
if (checkLanguage === null || checkLanguage.length === 0) {
localStorage.setItem('qortalLanguage', 'us')
use('us')
} else {
use(checkLanguage)
}
}
async checkAddressInfo() { async checkAddressInfo() {
let toCheck = this.checkleveladdress let toCheck = this.checkleveladdress
const memberInfo = await parentEpml.request('apiCall', { const memberInfo = await parentEpml.request('apiCall', {
@ -147,23 +123,23 @@ class LevelFounder extends LitElement {
} }
renderFounder() { renderFounder() {
let adressfounder = this.memberInfo.flags; let adressfounder = this.memberInfo.flags
if (adressfounder === 1) { if (adressfounder === 1) {
return html ` return html `
<span id="founderTooltip" class="badge">F</span> <span id="founderTooltip" class="badge">F</span>
<paper-tooltip class="custom" for="founderTooltip" position="top">FOUNDER</paper-tooltip> <paper-tooltip class="custom" for="founderTooltip" position="top">FOUNDER</paper-tooltip>
` `
} else { } else {
return null; return html ``
} }
} }
renderLevel() { renderLevel() {
let adresslevel = this.memberInfo.level; let adresslevel = this.memberInfo.level
return adresslevel ? html ` return adresslevel ? html `
<img id="level-img" src=${`/img/badges/level-${adresslevel}.png`} alt=${`badge-${adresslevel}`} class="message-data-level" /> <img id="level-img" src=${`/img/badges/level-${adresslevel}.png`} alt=${`badge-${adresslevel}`} class="message-data-level" />
<paper-tooltip class="level-img-tooltip" for="level-img" position="top" > <paper-tooltip class="level-img-tooltip" for="level-img" position="top" >
${translate("mintingpage.mchange27")} ${adresslevel} ${translate("mintingpage.mchange27")} ${adresslevel}
</paper-tooltip> </paper-tooltip>
` : '' ` : ''
} }
@ -174,9 +150,9 @@ class LevelFounder extends LitElement {
} }
getApiKey() { getApiKey() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
let apiKey = myNode.apiKey; let apiKey = myNode.apiKey
return apiKey; return apiKey
} }
} }

View File

@ -3,11 +3,6 @@ import { render } from 'lit/html.js'
import { Epml } from '../../../epml.js' import { Epml } from '../../../epml.js'
import snackbar from './snackbar.js' import snackbar from './snackbar.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate' import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
import '@material/mwc-snackbar' import '@material/mwc-snackbar'
import '@material/mwc-button' import '@material/mwc-button'
import '@material/mwc-dialog' import '@material/mwc-dialog'
@ -250,17 +245,12 @@ class NameMenu extends LitElement {
} }
firstUpdated() { firstUpdated() {
this.getChatBlockedAdresses(); this.getChatBlockedAdresses()
setInterval(() => { setInterval(() => {
this.getChatBlockedAdresses(); this.getChatBlockedAdresses()
}, 60000) }, 60000)
window.addEventListener('storage', () => {
const checkLanguage = localStorage.getItem('qortalLanguage');
use(checkLanguage);
})
window.onclick = function(event) { window.onclick = function(event) {
if (!event.target.matches('.block')) { if (!event.target.matches('.block')) {
var dropdowns = document.getElementsByClassName('dropdown-content'); var dropdowns = document.getElementsByClassName('dropdown-content');
@ -275,12 +265,12 @@ class NameMenu extends LitElement {
} }
const stopKeyEventPropagation = (e) => { const stopKeyEventPropagation = (e) => {
e.stopPropagation(); e.stopPropagation()
return false; return false
} }
this.shadowRoot.getElementById('sendTo').addEventListener('keydown', stopKeyEventPropagation); this.shadowRoot.getElementById('sendTo').addEventListener('keydown', stopKeyEventPropagation)
this.shadowRoot.getElementById('messageBox').addEventListener('keydown', stopKeyEventPropagation); this.shadowRoot.getElementById('messageBox').addEventListener('keydown', stopKeyEventPropagation)
const getDataFromURL = () => { const getDataFromURL = () => {
let tempUrl = document.location.href let tempUrl = document.location.href
@ -309,17 +299,6 @@ class NameMenu extends LitElement {
parentEpml.imReady() parentEpml.imReady()
} }
changeLanguage() {
const checkLanguage = localStorage.getItem('qortalLanguage')
if (checkLanguage === null || checkLanguage.length === 0) {
localStorage.setItem('qortalLanguage', 'us')
use('us')
} else {
use(checkLanguage)
}
}
myMenu() { myMenu() {
this.shadowRoot.getElementById('myDropdown').classList.toggle('showList') this.shadowRoot.getElementById('myDropdown').classList.toggle('showList')
this.shadowRoot.querySelector('#blockNameDialog').close() this.shadowRoot.querySelector('#blockNameDialog').close()

View File

@ -24,11 +24,11 @@ class TimeAgo extends LitElement {
} }
}); });
this.shadowRoot.querySelector('time-ago').setAttribute('title', ''); this.shadowRoot.querySelector('time-ago').setAttribute('title', '')
} }
constructor() { constructor() {
super(); super()
this.timestamp = 0 this.timestamp = 0
this.timeIso = '' this.timeIso = ''
this.format = '' this.format = ''
@ -41,7 +41,7 @@ class TimeAgo extends LitElement {
} }
renderTime(timestamp) { renderTime(timestamp) {
timestamp === undefined ? this.timeIso = '' : this.timeIso = new Date(timestamp).toISOString(); timestamp === undefined ? this.timeIso = '' : this.timeIso = new Date(timestamp).toISOString()
} }
firstUpdated() { firstUpdated() {

View File

@ -1,10 +1,10 @@
import { LitElement, html } from 'lit'; import { LitElement, html } from 'lit'
import { render } from 'lit/html.js'; import { render } from 'lit/html.js'
import { get, translate } from 'lit-translate'; import { tipUserStyles } from './TipUser-css.js'
import { tipUserStyles } from './TipUser-css.js'; import { Epml } from '../../../epml'
import { Epml } from '../../../epml'; import '@vaadin/button'
import '@vaadin/button'; import '@polymer/paper-progress/paper-progress.js'
import '@polymer/paper-progress/paper-progress.js'; import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: "WINDOW", source: window.parent }); const parentEpml = new Epml({ type: "WINDOW", source: window.parent });
@ -34,15 +34,15 @@ export class TipUser extends LitElement {
static styles = [tipUserStyles] static styles = [tipUserStyles]
async firstUpdated() { async firstUpdated() {
await this.fetchWalletDetails(); await this.fetchWalletDetails()
} }
updated(changedProperties) { updated(changedProperties) {
if (changedProperties && changedProperties.has("closeTipUser")) { if (changedProperties && changedProperties.has("closeTipUser")) {
if (this.closeTipUser) { if (this.closeTipUser) {
this.shadowRoot.getElementById("amountInput").value = ""; this.shadowRoot.getElementById("amountInput").value = ""
this.errorMessage = ""; this.errorMessage = ""
this.successMessage = ""; this.successMessage = ""
} }
} }
} }
@ -52,7 +52,7 @@ export class TipUser extends LitElement {
type: "api", type: "api",
url: `/addresses/lastreference/${this.myAddress.address}`, url: `/addresses/lastreference/${this.myAddress.address}`,
}) })
return myRef; return myRef
} }
renderSuccessText() { renderSuccessText() {
@ -64,9 +64,9 @@ export class TipUser extends LitElement {
} }
getApiKey() { getApiKey() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
let apiKey = myNode.apiKey; let apiKey = myNode.apiKey
return apiKey; return apiKey
} }
async fetchWalletDetails() { async fetchWalletDetails() {
@ -78,85 +78,85 @@ export class TipUser extends LitElement {
let snack4string = get("chatpage.cchange48") let snack4string = get("chatpage.cchange48")
parentEpml.request('showSnackBar', `${snack4string}`) parentEpml.request('showSnackBar', `${snack4string}`)
} else { } else {
this.walletBalance = Number(res).toFixed(8); this.walletBalance = Number(res).toFixed(8)
} }
}) })
} }
async sendQort() { async sendQort() {
const amount = this.shadowRoot.getElementById("amountInput").value; const amount = this.shadowRoot.getElementById("amountInput").value
let recipient = this.userName; let recipient = this.userName
this.sendMoneyLoading = true; this.sendMoneyLoading = true
this.btnDisable = true; this.btnDisable = true
if (parseFloat(amount) + parseFloat(0.001) > parseFloat(this.walletBalance)) { if (parseFloat(amount) + parseFloat(0.001) > parseFloat(this.walletBalance)) {
this.sendMoneyLoading = false; this.sendMoneyLoading = false
this.btnDisable = false; this.btnDisable = false
let snack1string = get("chatpage.cchange51"); let snack1string = get("chatpage.cchange51")
parentEpml.request('showSnackBar', `${snack1string}`); parentEpml.request('showSnackBar', `${snack1string}`)
return false; return false
} }
if (parseFloat(amount) <= 0) { if (parseFloat(amount) <= 0) {
this.sendMoneyLoading = false; this.sendMoneyLoading = false
this.btnDisable = false; this.btnDisable = false
let snack2string = get("chatpage.cchange52"); let snack2string = get("chatpage.cchange52")
parentEpml.request('showSnackBar', `${snack2string}`); parentEpml.request('showSnackBar', `${snack2string}`)
return false; return false
} }
if (recipient.length === 0) { if (recipient.length === 0) {
this.sendMoneyLoading = false; this.sendMoneyLoading = false
this.btnDisable = false; this.btnDisable = false
let snack3string = get("chatpage.cchange53"); let snack3string = get("chatpage.cchange53")
parentEpml.request('showSnackBar', `${snack3string}`); parentEpml.request('showSnackBar', `${snack3string}`)
return false; return false
} }
const validateName = async (receiverName) => { const validateName = async (receiverName) => {
let myRes; let myRes
let myNameRes = await parentEpml.request('apiCall', { let myNameRes = await parentEpml.request('apiCall', {
type: 'api', type: 'api',
url: `/names/${receiverName}`, url: `/names/${receiverName}`,
}) })
if (myNameRes.error === 401) { if (myNameRes.error === 401) {
myRes = false; myRes = false
} else { } else {
myRes = myNameRes; myRes = myNameRes
} }
return myRes; return myRes;
} }
const validateAddress = async (receiverAddress) => { const validateAddress = async (receiverAddress) => {
let myAddress = await window.parent.validateAddress(receiverAddress); let myAddress = await window.parent.validateAddress(receiverAddress)
return myAddress; return myAddress
} }
const validateReceiver = async (recipient) => { const validateReceiver = async (recipient) => {
let lastRef = await this.getLastRef(); let lastRef = await this.getLastRef()
let isAddress; let isAddress
try { try {
isAddress = await validateAddress(recipient); isAddress = await validateAddress(recipient)
} catch (err) { } catch (err) {
isAddress = false; isAddress = false
} }
if (isAddress) { if (isAddress) {
let myTransaction = await makeTransactionRequest(recipient, lastRef); let myTransaction = await makeTransactionRequest(recipient, lastRef)
getTxnRequestResponse(myTransaction); getTxnRequestResponse(myTransaction)
} else { } else {
let myNameRes = await validateName(recipient); let myNameRes = await validateName(recipient)
if (myNameRes !== false) { if (myNameRes !== false) {
let myNameAddress = myNameRes.owner let myNameAddress = myNameRes.owner
let myTransaction = await makeTransactionRequest(myNameAddress, lastRef) let myTransaction = await makeTransactionRequest(myNameAddress, lastRef)
getTxnRequestResponse(myTransaction) getTxnRequestResponse(myTransaction)
} else { } else {
console.error(this.renderReceiverText()) console.error(this.renderReceiverText())
this.errorMessage = this.renderReceiverText(); this.errorMessage = this.renderReceiverText()
this.sendMoneyLoading = false; this.sendMoneyLoading = false
this.btnDisable = false; this.btnDisable = false
} }
} }
} }
@ -169,23 +169,23 @@ export class TipUser extends LitElement {
}); });
if (getNames?.length > 0 ) { if (getNames?.length > 0 ) {
return getNames[0].name; return getNames[0].name
} else { } else {
return ''; return ''
} }
} catch (error) { } catch (error) {
return ""; return ""
} }
} }
const makeTransactionRequest = async (receiver, lastRef) => { const makeTransactionRequest = async (receiver, lastRef) => {
let myReceiver = receiver; let myReceiver = receiver
let mylastRef = lastRef; let mylastRef = lastRef
let dialogamount = get("transactions.amount"); let dialogamount = get("transactions.amount")
let dialogAddress = get("login.address"); let dialogAddress = get("login.address")
let dialogName = get("login.name"); let dialogName = get("login.name")
let dialogto = get("transactions.to"); let dialogto = get("transactions.to")
let recipientName = await getName(myReceiver); let recipientName = await getName(myReceiver)
let myTxnrequest = await parentEpml.request('transaction', { let myTxnrequest = await parentEpml.request('transaction', {
type: 2, type: 2,
nonce: this.myAddress.nonce, nonce: this.myAddress.nonce,
@ -201,33 +201,33 @@ export class TipUser extends LitElement {
dialogName dialogName
}, },
}) })
return myTxnrequest; return myTxnrequest
} }
const getTxnRequestResponse = (txnResponse) => { const getTxnRequestResponse = (txnResponse) => {
if (txnResponse.success === false && txnResponse.message) { if (txnResponse.success === false && txnResponse.message) {
this.errorMessage = txnResponse.message; this.errorMessage = txnResponse.message
this.sendMoneyLoading = false; this.sendMoneyLoading = false
this.btnDisable = false; this.btnDisable = false
throw new Error(txnResponse); throw new Error(txnResponse)
} else if (txnResponse.success === true && !txnResponse.data.error) { } else if (txnResponse.success === true && !txnResponse.data.error) {
this.shadowRoot.getElementById('amountInput').value = ''; this.shadowRoot.getElementById('amountInput').value = ''
this.errorMessage = ''; this.errorMessage = ''
this.successMessage = this.renderSuccessText(); this.successMessage = this.renderSuccessText()
this.sendMoneyLoading = false; this.sendMoneyLoading = false
this.btnDisable = false; this.btnDisable = false
setTimeout(() => { setTimeout(() => {
this.setOpenTipUser(false); this.setOpenTipUser(false)
this.successMessage = ""; this.successMessage = ""
}, 3000); }, 3000)
} else { } else {
this.errorMessage = txnResponse.data.message; this.errorMessage = txnResponse.data.message
this.sendMoneyLoading = false; this.sendMoneyLoading = false
this.btnDisable = false; this.btnDisable = false
throw new Error(txnResponse); throw new Error(txnResponse)
} }
} }
validateReceiver(recipient); validateReceiver(recipient)
} }
render() { render() {
@ -274,4 +274,4 @@ export class TipUser extends LitElement {
`; `;
} }
} }
customElements.define('tip-user', TipUser); customElements.define('tip-user', TipUser)

View File

@ -1,5 +1,6 @@
import { LitElement, html, css } from 'lit' import { LitElement, html, css } from 'lit'
import { Epml } from '../../../epml.js' import { Epml } from '../../../epml.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })

View File

@ -8,10 +8,6 @@ import { cropAddress } from '../../../utils/cropAddress.js'
import '@polymer/paper-progress/paper-progress.js' import '@polymer/paper-progress/paper-progress.js'
import '@vaadin/button' import '@vaadin/button'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
export class UserInfo extends LitElement { export class UserInfo extends LitElement {

View File

@ -1,33 +1,32 @@
import { LitElement, html } from 'lit'; import { LitElement, html } from 'lit'
import { render } from 'lit/html.js'; import { render } from 'lit/html.js'
import { wrapperModalStyles } from './WrapperModal-css.js' import { wrapperModalStyles } from './WrapperModal-css.js'
export class WrapperModal extends LitElement { export class WrapperModal extends LitElement {
static get properties() { static get properties() {
return { return {
customStyle: {type: String}, customStyle: {type: String},
onClickFunc: { attribute: false }, onClickFunc: { attribute: false },
zIndex: {type: Number} zIndex: {type: Number}
}
} }
}
static styles = [wrapperModalStyles] static styles = [wrapperModalStyles]
render() { render() {
return html` return html`
<div> <div>
<div <div
style="z-index: ${this.zIndex || 50}" style="z-index: ${this.zIndex || 50}"
class="backdrop" class="backdrop"
@click=${() => { @click=${() => { this.onClickFunc() }}
this.onClickFunc(); >
}}> </div>
</div> <div class="modal-body" style=${this.customStyle ? this.customStyle : ""}>
<div class="modal-body" style=${this.customStyle ? this.customStyle : ""}> <slot></slot>
<slot></slot> </div>
</div> </div>
</div> `
`; }
}
} }
customElements.define('wrapper-modal', WrapperModal); customElements.define('wrapper-modal', WrapperModal)

View File

@ -1,7 +1,6 @@
import { LitElement, html, css } from 'lit' import { LitElement, html, css } from 'lit'
import { render } from 'lit/html.js' import { render } from 'lit/html.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate' import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
import '@polymer/paper-dialog/paper-dialog.js' import '@polymer/paper-dialog/paper-dialog.js'
import '@material/mwc-button' import '@material/mwc-button'
import '@material/mwc-icon' import '@material/mwc-icon'

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ import '../../components/ChatWelcomePage.js'
import '../../components/ChatHead.js' import '../../components/ChatHead.js'
import '../../components/ChatPage.js' import '../../components/ChatPage.js'
import '../../components/WrapperModal.js' import '../../components/WrapperModal.js'
import '../../components/ChatSeachResults.js' import '../../components/ChatSearchResults.js'
import '@material/mwc-button' import '@material/mwc-button'
import '@material/mwc-dialog' import '@material/mwc-dialog'
@ -27,10 +27,6 @@ import '@material/mwc-snackbar'
import '@polymer/paper-spinner/paper-spinner-lite.js' import '@polymer/paper-spinner/paper-spinner-lite.js'
import '@vaadin/grid' import '@vaadin/grid'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
passiveSupport({ events: ['touchstart'] }) passiveSupport({ events: ['touchstart'] })
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
@ -149,7 +145,6 @@ class Chat extends LitElement {
] ]
}) })
this.unsubscribeStore = window.parent.reduxStore.subscribe(() => { this.unsubscribeStore = window.parent.reduxStore.subscribe(() => {
try { try {
if(window.parent.location && window.parent.location.search) { if(window.parent.location && window.parent.location.search) {
@ -381,7 +376,6 @@ class Chat extends LitElement {
} }
async firstUpdated() { async firstUpdated() {
this.changeLanguage()
this.changeTheme() this.changeTheme()
this.getChatBlockedList() this.getChatBlockedList()
this.getLocalBlockedList() this.getLocalBlockedList()
@ -429,11 +423,8 @@ class Chat extends LitElement {
let runFunctionsAfterPageLoadInterval = setInterval(runFunctionsAfterPageLoad, 100) let runFunctionsAfterPageLoadInterval = setInterval(runFunctionsAfterPageLoad, 100)
window.addEventListener('storage', () => { window.addEventListener('storage', () => {
const checkLanguage = localStorage.getItem('qortalLanguage')
const checkTheme = localStorage.getItem('qortalTheme') const checkTheme = localStorage.getItem('qortalTheme')
use(checkLanguage)
if (checkTheme === 'dark') { if (checkTheme === 'dark') {
this.theme = 'dark' this.theme = 'dark'
} else { } else {
@ -802,17 +793,6 @@ class Chat extends LitElement {
document.querySelector('html').setAttribute('theme', this.theme) document.querySelector('html').setAttribute('theme', this.theme)
} }
changeLanguage() {
const checkLanguage = localStorage.getItem('qortalLanguage')
if (checkLanguage === null || checkLanguage.length === 0) {
localStorage.setItem('qortalLanguage', 'us')
use('us')
} else {
use(checkLanguage)
}
}
renderChatWelcomePage() { renderChatWelcomePage() {
return html` return html`
<chat-welcome-page <chat-welcome-page