this.openDeleteImage = false}>
+
+ (this.openDeleteImage = false)}>
@@ -1777,242 +2328,290 @@ MessageTemplate
hideActions
?open=${this.openDeleteAttachment}
@closed=${() => {
- this.openDeleteAttachment = false
- }}>
+ this.openDeleteAttachment = false;
+ }}>
-
${translate("chatpage.cchange79")}
+
${translate('chatpage.cchange79')}
-
this.openDeleteAttachment = false}>
+
+ (this.openDeleteAttachment = false)}>
- `
- }
+ `;
+ }
}
-window.customElements.define('message-template', MessageTemplate)
+window.customElements.define('message-template', MessageTemplate);
class ChatMenu extends LitElement {
- static get properties() {
- return {
- menuItems: { type: Array },
- showPrivateMessageModal: { attribute: false },
- showBlockUserModal: { attribute: false },
- toblockaddress: { type: String, attribute: true },
- showBlockIconFunc: { attribute: false },
- showBlockAddressIcon: { type: Boolean },
- originalMessage: { type: Object },
- setRepliedToMessageObj: { attribute: false },
- setEditedMessageObj: { attribute: false },
- myAddress: { type: Object },
- emojiPicker: { attribute: false },
- sendMessage: { attribute: false },
- version: { type: String },
- setToggledMessage: { attribute: false },
- sendMessageForward: { attribute: false },
- setForwardProperties: { attribute: false },
- firstMessageInChat: { type: Boolean },
- setOpenPrivateMessage: { attribute: false },
- setOpenTipUser: { attribute: false },
- setUserName: { attribute: false },
- gif: { type: Boolean }
- }
- }
+ static get properties() {
+ return {
+ menuItems: { type: Array },
+ showPrivateMessageModal: { attribute: false },
+ showBlockUserModal: { attribute: false },
+ toblockaddress: { type: String, attribute: true },
+ showBlockIconFunc: { attribute: false },
+ showBlockAddressIcon: { type: Boolean },
+ originalMessage: { type: Object },
+ setRepliedToMessageObj: { attribute: false },
+ setEditedMessageObj: { attribute: false },
+ myAddress: { type: Object },
+ emojiPicker: { attribute: false },
+ sendMessage: { attribute: false },
+ version: { type: String },
+ setToggledMessage: { attribute: false },
+ sendMessageForward: { attribute: false },
+ setForwardProperties: { attribute: false },
+ firstMessageInChat: { type: Boolean },
+ setOpenPrivateMessage: { attribute: false },
+ setOpenTipUser: { attribute: false },
+ setUserName: { attribute: false },
+ gif: { type: Boolean },
+ };
+ }
- constructor() {
- super()
- this.showPrivateMessageModal = () => { }
- this.showBlockUserModal = () => { }
- }
+ constructor() {
+ super();
+ this.showPrivateMessageModal = () => {};
+ this.showBlockUserModal = () => {};
+ }
- static get styles() {
- return [chatStyles]
- }
+ static get styles() {
+ return [chatStyles];
+ }
- // Copy address to clipboard
- async copyToClipboard(text) {
- try {
- let copyString1 = get("walletpage.wchange4")
- await navigator.clipboard.writeText(text)
- parentEpml.request('showSnackBar', `${copyString1}`)
- } catch (err) {
- let copyString2 = get("walletpage.wchange39")
- parentEpml.request('showSnackBar', `${copyString2}`)
- console.error('Copy to clipboard error:', err)
- }
- }
+ // Copy address to clipboard
+ async copyToClipboard(text) {
+ try {
+ let copyString1 = get('walletpage.wchange4');
+ await navigator.clipboard.writeText(text);
+ parentEpml.request('showSnackBar', `${copyString1}`);
+ } catch (err) {
+ let copyString2 = get('walletpage.wchange39');
+ parentEpml.request('showSnackBar', `${copyString2}`);
+ console.error('Copy to clipboard error:', err);
+ }
+ }
- versionErrorSnack() {
- let errorMsg = get("chatpage.cchange34")
- parentEpml.request('showSnackBar', `${errorMsg}`)
- }
+ versionErrorSnack() {
+ let errorMsg = get('chatpage.cchange34');
+ parentEpml.request('showSnackBar', `${errorMsg}`);
+ }
- async messageForwardFunc() {
- let parsedMessageObj = {}
- let publicKey = {
- hasPubKey: false,
- key: ''
- }
- try {
- parsedMessageObj = JSON.parse(this.originalMessage.decodedMessage)
+ async messageForwardFunc() {
+ let parsedMessageObj = {};
+ let publicKey = {
+ hasPubKey: false,
+ key: '',
+ };
+ try {
+ parsedMessageObj = JSON.parse(this.originalMessage.decodedMessage);
+ } catch (error) {
+ parsedMessageObj = {};
+ }
- } catch (error) {
- parsedMessageObj = {}
- }
+ try {
+ const res = await parentEpml.request('apiCall', {
+ type: 'api',
+ url: `/addresses/publickey/${this._chatId}`,
+ });
+ if (res.error === 102) {
+ publicKey.key = '';
+ publicKey.hasPubKey = false;
+ } else if (res !== false) {
+ publicKey.key = res;
+ publicKey.hasPubKey = true;
+ } else {
+ publicKey.key = '';
+ publicKey.hasPubKey = false;
+ }
+ } catch (error) {}
- try {
- const res = await parentEpml.request('apiCall', {
- type: 'api',
- url: `/addresses/publickey/${this._chatId}`
- })
- if (res.error === 102) {
- publicKey.key = ''
- publicKey.hasPubKey = false
- } else if (res !== false) {
- publicKey.key = res
- publicKey.hasPubKey = true
- } else {
- publicKey.key = ''
- publicKey.hasPubKey = false
- }
- } catch (error) {
-
- }
-
- try {
- const message = {
- ...parsedMessageObj,
- type: 'forward'
- }
- const stringifyMessageObject = JSON.stringify(message)
- this.setForwardProperties(stringifyMessageObject)
-
- } catch (error) {
- }
- }
- render() {
- return html`
-
-
-
-
-
-
-
- ${((this.myAddress === this.originalMessage.sender) && (
- !this.gif)) ? (
- html`
-
- `
- ) : html`
`}
- ${this.myAddress !== this.originalMessage.sender ? (
- html`
-
- `
- ) : html`
`}
-
- ${this.showBlockAddressIcon
- ? html`
-
-
this.showBlockUserModal()}">
-
${translate("blockpage.bcchange1")}
-
-
-
- ` : html`
-
- `
- }
-
- `
- }
+
+
+
+
+
+ ${this.myAddress === this.originalMessage.sender && !this.gif
+ ? html`
+
+ `
+ : html`
`}
+ ${this.myAddress !== this.originalMessage.sender
+ ? html`
+
+ `
+ : html`
`}
+
+ ${this.showBlockAddressIcon
+ ? html`
+
+
this.showBlockUserModal()}"
+ >
+
${translate('blockpage.bcchange1')}
+
+
+
+ `
+ : html`
`}
+
+ `;
+ }
}
-window.customElements.define('chat-menu', ChatMenu)
+window.customElements.define('chat-menu', ChatMenu);
diff --git a/plugins/plugins/core/components/ImageComponent.js b/plugins/plugins/core/components/ImageComponent.js
index cb35702c..80bb6c26 100644
--- a/plugins/plugins/core/components/ImageComponent.js
+++ b/plugins/plugins/core/components/ImageComponent.js
@@ -1,126 +1,133 @@
-import { LitElement, html, css } from 'lit'
-import { render } from 'lit/html.js'
-import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
+import { LitElement, html, css } from 'lit';
+import { render } from 'lit/html.js';
+import {
+ use,
+ get,
+ translate,
+ translateUnsafeHTML,
+ registerTranslateConfig,
+} from 'lit-translate';
export class ImageComponent extends LitElement {
-
-static get properties() {
-return {
-class: { type: String },
-gif: { type: Object },
-alt: { type: String },
-attempts: { type: Number },
-maxAttempts: { type: Number },
-error: { type: Boolean },
-sendMessage: { attribute: false },
-setOpenGifModal: { attribute: false }
-}
-}
-
-static get styles() {
-return css`
-.gif-error-msg {
-margin: 0;
-font-family: Roboto, sans-serif;
-font-size: 17px;
-letter-spacing: 0.3px;
-color: var(--chat-bubble-msg-color);
-font-weight: 300;
-padding: 10px 10px;
-}
-
-.gif-image {
-border-radius: 15px;
-background-color: transparent;
-cursor: pointer;
-width: 100%;
-height: 150px;
-object-fit: cover;
-border: 1px solid transparent;
-transition: all 0.2s cubic-bezier(0, 0.55, 0.45, 1);
-box-shadow: rgb(50 50 93 / 25%) 0px 6px 12px -2px, rgb(0 0 0 / 30%) 0px 3px 7px -3px;
-}
-
-.gif-image:hover {
-border: 1px solid var(--mdc-theme-primary );
-}
-`
-}
-
-constructor() {
- super()
- this.attempts = 0
- this.maxAttempts = 5
-}
-getApiKey() {
- const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
- let apiKey = myNode.apiKey
- return apiKey
-}
-
-async _fetchImage() {
- this.attempts++;
- if (this.attempts > this.maxAttempts) return
- await new Promise((res) => {
- setTimeout(() => {
- res()
- }, 1000)
- })
- try {
- const response = await fetch(this.gif.url)
- const data = await response.json()
- if (data.ok) {
- this.error = false
- this.gif = {
- ...this.gif,
- url: data.src
+ static get properties() {
+ return {
+ class: { type: String },
+ gif: { type: Object },
+ alt: { type: String },
+ attempts: { type: Number },
+ maxAttempts: { type: Number },
+ error: { type: Boolean },
+ sendMessage: { attribute: false },
+ setOpenGifModal: { attribute: false },
};
- this.requestUpdate();
- } else if (!data.ok || data.error) {
- this.error = true
- } else {
- this.error = false
+ }
+
+ static get styles() {
+ return css`
+ .gif-error-msg {
+ margin: 0;
+ font-family: Roboto, sans-serif;
+ font-size: 17px;
+ letter-spacing: 0.3px;
+ color: var(--chat-bubble-msg-color);
+ font-weight: 300;
+ padding: 10px 10px;
+ }
+
+ .gif-image {
+ border-radius: 15px;
+ background-color: transparent;
+ cursor: pointer;
+ width: 100%;
+ height: 150px;
+ object-fit: cover;
+ border: 1px solid transparent;
+ transition: all 0.2s cubic-bezier(0, 0.55, 0.45, 1);
+ box-shadow: rgb(50 50 93 / 25%) 0px 6px 12px -2px,
+ rgb(0 0 0 / 30%) 0px 3px 7px -3px;
+ }
+
+ .gif-image:hover {
+ border: 1px solid var(--mdc-theme-primary);
+ }
+ `;
+ }
+
+ constructor() {
+ super();
+ this.attempts = 0;
+ this.maxAttempts = 5;
+ }
+ getApiKey() {
+ const myNode =
+ window.parent.reduxStore.getState().app.nodeConfig.knownNodes[
+ window.parent.reduxStore.getState().app.nodeConfig.node
+ ];
+ let apiKey = myNode.apiKey;
+ return apiKey;
+ }
+
+ async _fetchImage() {
+ this.attempts++;
+ if (this.attempts > this.maxAttempts) return;
+ await new Promise((res) => {
+ setTimeout(() => {
+ res();
+ }, 1000);
+ });
+ try {
+ const response = await fetch(this.gif.url);
+ const data = await response.json();
+ if (data.ok) {
+ this.error = false;
+ this.gif = {
+ ...this.gif,
+ url: data.src,
+ };
+ this.requestUpdate();
+ } else if (!data.ok || data.error) {
+ this.error = true;
+ } else {
+ this.error = false;
+ }
+ } catch (error) {
+ this.error = true;
+ console.error(error);
+ this._fetchImage();
}
- } catch (error) {
- this.error = true
- console.error(error)
- this._fetchImage()
+ }
+
+ render() {
+ if (this.error && this.attempts <= this.maxAttempts) {
+ setTimeout(() => {
+ this._fetchImage();
+ }, 1000);
+ }
+ return html` ${this.gif && !this.error
+ ? html`

{
+ this.sendMessage({
+ type: 'gif',
+ identifier: this.gif.identifier,
+ name: this.gif.name,
+ filePath: this.gif.filePath,
+ service: 'GIF_REPOSITORY',
+ });
+ this.setOpenGifModal(false);
+ }}
+ @error=${this._fetchImage}
+ />`
+ : this.error && this.attempts <= this.maxAttempts
+ ? html`
+
${translate('gifs.gchange15')}
+ `
+ : html`
+
${translate('gifs.gchange16')}
+ `}`;
}
}
-render() {
-if (this.error && this.attempts <= this.maxAttempts) {
- setTimeout(() => {
- this._fetchImage()
- }, 1000)
-}
-return html`
-${this.gif && !this.error
- ? html`
-
![]()
{
- this.sendMessage({
- type: 'gif',
- identifier: this.gif.identifier,
- name: this.gif.name,
- filePath: this.gif.filePath,
- service: "GIF_REPOSITORY"
- })
- this.setOpenGifModal(false);
-}}
-@error=${this._fetchImage}
-/>`
- : this.error && this.attempts <= this.maxAttempts ? html`
-
${translate('gifs.gchange15')}
-`
- : html`
-
${translate('gifs.gchange16')}
- `
-}`
-}
-}
-
-customElements.define('image-component', ImageComponent)
+customElements.define('image-component', ImageComponent);
diff --git a/plugins/plugins/utils/queue.js b/plugins/plugins/utils/queue.js
index d6130f8c..00a235e6 100644
--- a/plugins/plugins/utils/queue.js
+++ b/plugins/plugins/utils/queue.js
@@ -32,3 +32,40 @@ export class RequestQueue {
}
}
+export class RequestQueueWithPromise {
+ constructor(maxConcurrent = 5) {
+ this.queue = [];
+ this.maxConcurrent = maxConcurrent;
+ this.currentlyProcessing = 0;
+ }
+
+ // Add a request to the queue and return a promise
+ enqueue(request) {
+ return new Promise((resolve, reject) => {
+ // Push the request and its resolve and reject callbacks to the queue
+ this.queue.push({ request, resolve, reject });
+ this.process();
+ });
+ }
+
+ // Process requests in the queue
+ async process() {
+ while (this.queue.length > 0 && this.currentlyProcessing < this.maxConcurrent) {
+ this.currentlyProcessing++;
+ const { request, resolve, reject } = this.queue.shift();
+ try {
+ const response = await request();
+ resolve(response);
+ } catch (error) {
+ reject(error);
+ } finally {
+ this.currentlyProcessing--;
+ this.process();
+ }
+ }
+ }
+ }
+
+
+
+