Merge branch 'Qortal:master' into master

This commit is contained in:
kennycud
2025-02-14 11:27:46 -08:00
committed by GitHub
14 changed files with 259 additions and 171 deletions

View File

@@ -5,7 +5,7 @@ import localForage from 'localforage'
import '@material/mwc-icon'
// Multi language support
import { translate } from '../../../../core/translate'
import { get, translate } from '../../../../core/translate'
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
@@ -66,6 +66,9 @@ class ChatHead extends LitElement {
} else if (groupString === 'Group_1') {
const avatarUrl = `/img/qdcgroup.png`
this.avatarImg = this.createImage(avatarUrl)
} else if (groupString === 'Group_694') {
const avatarUrl = `/img/minter.png`
this.avatarImg = this.createImage(avatarUrl)
} else if (this.chatInfo.name) {
const avatarUrl = `${nodeUrl}/arbitrary/THUMBNAIL/${this.chatInfo.name}/qortal_avatar?async=true`
this.avatarImg = this.createImage(avatarUrl)
@@ -129,12 +132,24 @@ class ChatHead extends LitElement {
>
${this.chatInfo.groupName ? this.chatInfo.groupName : this.chatInfo.name !== undefined ? this.chatInfo.name : this.chatInfo.address.substr(0, 15)}
</span>
<mwc-icon style="font-size:18px; color: var(--chat-group);">${this.chatInfo.groupId !== undefined ? 'lock_open' : 'lock'}</mwc-icon>
<mwc-icon
style="font-size:18px; color:${
this.chatInfo.groupId === undefined ? '#f0ad4e' :
this.chatInfo.isOpen === false ? '#C6011F' :
this.chatInfo.isOpen === true ? '#198754' : '#198754'}"
>
${
this.chatInfo.groupId === undefined ? 'private_connectivity' :
this.chatInfo.isOpen === false ? 'lock_outline' :
this.chatInfo.isOpen === true ? 'lock_open' :
'lock_open'
}
</mwc-icon>
</div>
</div>
<div class="about" style="margin-top:7px">
<div class="name">
<span style="float:left; padding-left: 8px; color: var(--chat-group);font-size:12px">${this.chatInfo.groupId !== undefined ? 'id: ' + this.chatInfo.groupId : ''}</span>
<span style="float:left; padding-left: 8px; color: var(--chat-group);font-size:12px">${this.chatInfo.groupId !== undefined ? 'id: ' + this.chatInfo.groupId : 'Private Chat'}</span>
<div style="color: var(--black); display: flex;font-size: 12px; align-items:center">
<div style="width: 8px; height: 8px;border-radius: 50%;background: ${isUnread ? 'var(--error)' : 'none'} ; margin-right:5px;"></div>
<message-time style="display: ${(this.chatInfo.timestamp && this.chatInfo.timestamp > 100000) ? 'block' : 'none'}" timestamp=${this.chatInfo.timestamp}></message-time>

View File

@@ -3,7 +3,7 @@ import { ifDefined } from 'lit/directives/if-defined.js'
import { unsafeHTML } from 'lit/directives/unsafe-html.js'
import { animate } from '@lit-labs/motion'
import { Epml } from '../../../epml'
import { Editor, Extension, generateHTML } from '@tiptap/core'
import { Editor, Extension, generateHTML, generateJSON } from '@tiptap/core'
import { escape } from 'html-escaper'
import { inputKeyCodes, replaceMessagesEdited, generateIdFromAddresses } from '../../utils/functions'
import { publishData, modalHelper, RequestQueue } from '../../utils/classes'
@@ -345,7 +345,12 @@ class ChatPage extends LitElement {
}
${+this.repliedToMessageObj.version > 1 ?
html`
<span style="color: var(--black);">${unsafeHTML(generateHTML(this.repliedToMessageObj.message, [StarterKit, Underline, Highlight, Mention]))}</span>
<span style="color: var(--black);">
${this.repliedToMessageObj.decodedMessage.includes('specialId') ?
this.convertHubMessageToJson(this.repliedToMessageObj.message) :
unsafeHTML(generateHTML(this.repliedToMessageObj.message, [StarterKit, Underline, Highlight, Mention]))
}
</span>
`
: ''
}
@@ -362,7 +367,12 @@ class ChatPage extends LitElement {
<vaadin-icon class="reply-icon" icon="vaadin:pencil" slot="icon"></vaadin-icon>
<div class="repliedTo-message">
<p class="senderName">${translate("chatpage.cchange25")}</p>
<span style="color: var(--black);">${unsafeHTML(generateHTML(this.editedMessageObj.message, [StarterKit, Underline, Highlight, Mention]))}</span>
<span style="color: var(--black);">
${this.editedMessageObj.decodedMessage.includes('specialId') && !this.editedMessageObj.decodedMessage.includes('messageText') ?
this.convertHubMessageToJson(this.editedMessageObj.message) :
unsafeHTML(generateHTML(this.editedMessageObj.message, [StarterKit, Underline, Highlight, Mention]))
}
</span>
</div>
<vaadin-icon class="close-icon" icon="vaadin:close-big" slot="icon" @click=${() => this.closeEditMessageContainer()}></vaadin-icon>
</div>
@@ -845,7 +855,12 @@ class ChatPage extends LitElement {
if (isEnabledChatEnter) {
this.isEnabledChatEnter = isEnabledChatEnter === 'false' ? false : true
}
}
convertHubMessageToJson(message) {
let newJson = generateJSON(`${message}`, [StarterKit, Underline, Highlight, Mention])
return unsafeHTML(generateHTML(newJson, [StarterKit, Underline, Highlight, Mention]))
}
getNodeUrl() {

View File

@@ -3,7 +3,7 @@ import { repeat } from 'lit/directives/repeat.js'
import { unsafeHTML } from 'lit/directives/unsafe-html.js'
import { Epml } from '../../../epml'
import { cropAddress, roundToNearestDecimal } from '../../utils/functions'
import { generateHTML } from '@tiptap/core'
import { generateHTML, generateJSON } from '@tiptap/core'
import { chatLimit, totalMsgCount } from './ChatPage'
import { chatStyles } from './plugins-css'
import isElectron from 'is-electron'
@@ -280,6 +280,7 @@ class ChatScroller extends LitElement {
render() {
let formattedMessages = this.messagesToRender
return html`
${this.isLoadingBefore
? html`
@@ -1091,7 +1092,7 @@ class MessageTemplate extends LitElement {
messageVersion2WithLink = processText(messageVersion2)
}
if (parsedMessageObj.version > 1 && parsedMessageObj.message) {
if (parsedMessageObj.version > 1 && parsedMessageObj.message && !parsedMessageObj.messageText) {
messageVersion2 = parsedMessageObj.message
messageVersion2WithLink = processText(messageVersion2)
}
@@ -1106,7 +1107,7 @@ class MessageTemplate extends LitElement {
version = parsedMessageObj.version
isForwarded = parsedMessageObj.type === 'forward'
isEdited = parsedMessageObj.isEdited && true
isEncrypted = parsedMessageObj.isFromHub || parsedMessageObj.message ? true : false
isEncrypted = parsedMessageObj.isFromHub || parsedMessageObj.isFrivate || parsedMessageObj.message ? true : false
if (parsedMessageObj.images && Array.isArray(parsedMessageObj.images) && parsedMessageObj.images.length > 0) {
image = parsedMessageObj.images[0]
@@ -1271,6 +1272,10 @@ class MessageTemplate extends LitElement {
try {
repliedToMessageText = generateHTML(repliedToData.decodedMessage.messageText, [StarterKit, Underline, Highlight, Mention])
} catch (error) { /* empty */ }
} else if (repliedToData && repliedToData.decodedMessage && repliedToData.decodedMessage.message) {
try {
repliedToMessageText = this.convertHubMessageToJson(repliedToData.decodedMessage.message)
} catch (error) { /* empty */ }
}
let replacedMessage = ''
@@ -2072,6 +2077,11 @@ class MessageTemplate extends LitElement {
}, 60000)
}
convertHubMessageToJson(message) {
let newJson = generateJSON(`${message}`, [StarterKit, Underline, Highlight, Mention])
return generateHTML(newJson, [StarterKit, Underline, Highlight, Mention])
}
async closeDownloadProgressDialog() {
const closeDelay = ms => new Promise(res => setTimeout(res, ms))
this.shadowRoot.getElementById('downloadProgressDialog').close()
@@ -2355,7 +2365,13 @@ class ChatMenu extends LitElement {
<div
class=${`menu-icon ${!this.firstMessageInChat ? 'tooltip' : ''}`}
data-text="${translate('blockpage.bcchange12')}"
@click=${() => {if (this.version === '0') {this.versionErrorSnack(); return;} this.setEditedMessageObj(this.originalMessage);}}
@click=${() => {
if (this.version === '0') {
this.versionErrorSnack();
return;
}
this.setEditedMessageObj(this.originalMessage);
}}
>
<vaadin-icon icon="vaadin:pencil" slot="icon"></vaadin-icon>
</div>

View File

@@ -1649,7 +1649,7 @@ export const chatStyles = css`
position: absolute;
top: 5px;
left: 10px;
height: 75%;
height: 85%;
width: 2.6px;
background-color: var(--mdc-theme-primary);
}
@@ -1669,7 +1669,7 @@ export const chatStyles = css`
overflow: hidden;
text-overflow: ellipsis;
max-width: 500px;
max-height: 40px;
max-height: 80px;
margin: 0;
padding: 0;
}
@@ -8524,7 +8524,7 @@ export const groupManagementStyles = css`
position: absolute;
top: 5px;
left: 10px;
height: 75%;
height: 85%;
width: 2.6px;
background-color: var(--mdc-theme-primary);
}
@@ -8548,7 +8548,7 @@ export const groupManagementStyles = css`
overflow: hidden;
text-overflow: ellipsis;
max-width: 500px;
max-height: 40px;
max-height: 80px;
margin: 0;
padding: 0;
}

View File

@@ -2893,6 +2893,14 @@ export const decryptChatMessageBase64 = (encryptedMessage, privateKey, recipient
return _decryptedMessage
}
let decrypted1 = new TextDecoder('utf-8').decode(_decryptedMessage)
if (decrypted1.includes('messageText')) {
let decrypted2 = JSON.parse(decrypted1)
let decrypted3 = Object.assign(decrypted2, {isFrivate: true})
return JSON.stringify(decrypted3)
}
return new TextDecoder('utf-8').decode(_decryptedMessage)
}

View File

@@ -12,6 +12,7 @@ import '@vaadin/grid'
// Multi language support
import { get, registerTranslateConfig, translate, use } from '../../../../core/translate'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
@@ -427,7 +428,9 @@ class NodeManagement extends LitElement {
async addPeer() {
this.addPeerLoading = true
const addPeerAddress = this.shadowRoot.getElementById('addPeerAddress').value
await parentEpml.request('apiCall', {
url: `/peers?apiKey=${this.getApiKey()}`,
method: 'POST',
@@ -456,7 +459,6 @@ class NodeManagement extends LitElement {
addMintingAccount() {
this.addMintingAccountLoading = true
this.addMintingAccountMessage = 'Loading...'
this.addMintingAccountKey = this.shadowRoot.querySelector('#addMintingAccountKey').value
parentEpml.request('apiCall', {
@@ -479,6 +481,7 @@ class NodeManagement extends LitElement {
updateMintingAccounts() {
this.mintingAccounts = []
parentEpml.request('apiCall', {
url: `/admin/mintingaccounts?apiKey=${this.getApiKey()}`,
method: 'GET'
@@ -518,10 +521,6 @@ class NodeManagement extends LitElement {
if (!arr) { return true }
return arr.length === 0
}
round(number) {
return (Math.round(parseFloat(number) * 1e8) / 1e8).toFixed(8)
}
}
window.customElements.define('node-management', NodeManagement)

View File

@@ -10,6 +10,7 @@ import '@vaadin/button'
// Multi language support
import { get, registerTranslateConfig, translate, use } from '../../../../core/translate'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
@@ -144,7 +145,6 @@ class OverviewPage extends LitElement {
async firstUpdated() {
this.changeTheme()
this.changeLanguage()
this.nodeConfig = window.parent.reduxStore.getState().app.nodeConfig
this.accountInfo = window.parent.reduxStore.getState().app.accountInfo
@@ -199,11 +199,13 @@ class OverviewPage 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)
}
@@ -225,6 +227,7 @@ class OverviewPage extends LitElement {
async refreshItems() {
this.nodeConfig = window.parent.reduxStore.getState().app.nodeConfig
this.accountInfo = window.parent.reduxStore.getState().app.accountInfo
await this.getNodeInfo()
await this.getCoreInfo()
await this.getBalanceInfo()
@@ -234,12 +237,14 @@ class OverviewPage extends LitElement {
async getMintingKeysList() {
this.check1 = false
this.check2 = false
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
const nodeStatus = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
const statusUrl = `${nodeStatus}/admin/mintingaccounts`
const statusUrl = `${nodeStatus}/admin/mintingaccounts?apiKey=${this.getApiKey()}`
try {
const res = await fetch(statusUrl)
this.listAccounts = await res.json()
const addressInfo = window.parent.reduxStore.getState().app.accountInfo.addressInfo
@@ -249,7 +254,6 @@ class OverviewPage extends LitElement {
const findRemovedSponsorsKey = this.listAccounts.filter((my) => my.address)
this.check1 = findMyMintingAccount !== undefined
this.check2 = findMyMintingRecipient !== undefined
if (findRemovedSponsorsKey.length > 0) {
@@ -285,8 +289,7 @@ class OverviewPage extends LitElement {
this.cssStatus = ''
return html`<span class="btn btn-sm btn-info float-right">${translate("walletprofile.wp1")}</span>`
} else if (this.nodeInfo.isMintingPossible === true && this.nodeInfo.isSynchronizing === false && this.check1 === false && this.check2 === true && addressInfo.level == 0 && addressInfo.blocksMinted < 7200) {
this.cssStatus = ''
return html`<span class="btn btn-sm btn-info float-right">${translate("becomeMinterPage.bchange12")}</span>`
return html`<span class="float-right"><start-minting-now></start-minting-now></span>`
} else if (this.check1 === false && this.check2 === false && myMintingKey === true) {
return html`<span class="float-right"><start-minting-now></start-minting-now></span>`
} else if (myMintingKey === false) {
@@ -319,6 +322,7 @@ class OverviewPage extends LitElement {
const infoNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
const infoNodeUrl = infoNode.protocol + '://' + infoNode.domain + ':' + infoNode.port
const nodeUrl = `${infoNodeUrl}/admin/status`
await fetch(nodeUrl).then(response => {
return response.json()
}).then(data => {
@@ -332,6 +336,7 @@ class OverviewPage extends LitElement {
const infoCore = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
const infoCoreUrl = infoCore.protocol + '://' + infoCore.domain + ':' + infoCore.port
const coreUrl = `${infoCoreUrl}/admin/info`
await fetch(coreUrl).then(response => {
return response.json()
}).then(data => {
@@ -344,6 +349,7 @@ class OverviewPage extends LitElement {
const infoBalance = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
const infoBalanceUrl = infoBalance.protocol + '://' + infoBalance.domain + ':' + infoBalance.port
const balanceUrl = `${infoBalanceUrl}/addresses/balance/${this.accountInfo.addressInfo.address}`
await fetch(balanceUrl).then(response => {
return response.json()
}).then(data => {
@@ -422,7 +428,7 @@ class StartMintingNow extends LitElement {
async getMintingAcccounts() {
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 url = `${nodeUrl}/admin/mintingaccounts`
const url = `${nodeUrl}/admin/mintingaccounts?apiKey=${this.getApiKey()}`
try {
const res = await fetch(url)
this.mintingAccountData = await res.json()
@@ -484,7 +490,9 @@ class StartMintingNow extends LitElement {
let interval = null
let stop = false
this.status = 2
const getAnswer = async () => {
const rewardShares = async (minterAddr) => {
const url = `${nodeUrl}/addresses/rewardshares?minters=${minterAddr}&recipients=${minterAddr}`
@@ -508,6 +516,7 @@ class StartMintingNow extends LitElement {
stop = false
}
}
interval = setInterval(getAnswer, 5000)
}

View File

@@ -1207,6 +1207,20 @@ class Chat extends LitElement {
}
}
async getGroupType(newGroupId) {
try {
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 response = await fetch(`${nodeUrl}/groups/${newGroupId}`)
const data = await response.json()
return data.isOpen
} catch (error) {
console.error('Error fetching group type', error)
throw error
}
}
async setChatHeads(chatObj) {
const chatObjGroups = Array.isArray(chatObj.groups) ? chatObj.groups : []
const chatObjDirect = Array.isArray(chatObj.direct) ? chatObj.direct : []
@@ -1216,12 +1230,14 @@ class Chat extends LitElement {
url: `group/${group.groupId}`,
groupName: 'Qortal General Chat',
timestamp: group.timestamp === undefined ? 2 : group.timestamp,
sender: group.sender
sender: group.sender,
isOpen: true
} : {
...group,
timestamp: group.timestamp === undefined ? 1 : group.timestamp,
url: `group/${group.groupId}`,
ownerName: group.ownerName === undefined ? await this.getOwnerName(group.groupId) : 'undefined'
ownerName: group.ownerName === undefined ? await this.getOwnerName(group.groupId) : 'undefined',
isOpen: group.isOpen === undefined ? await this.getGroupType(group.groupId) : true
}))
let directList = chatObjDirect.map(dc => {

View File

@@ -13,6 +13,7 @@ import '@vaadin/grid'
// Multi language support
import { get, registerTranslateConfig, translate, use } from '../../../../core/translate'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
@@ -361,7 +362,6 @@ class RewardShare extends LitElement {
getTxnRequestResponse(myTransaction)
}
} else if (accountDetails.level >= 5) {
this.error = false
this.message = ''
let myTransaction = await makeTransactionRequest(lastRef)
@@ -519,7 +519,6 @@ class RewardShare extends LitElement {
getTxnRequestResponse(myTransaction)
}
} else if (accountDetails.level >= 5) {
this.error = false
this.message = ''
let myTransaction = await makeTransactionRequest(lastRef)