diff --git a/qortal-ui-plugins/plugins/core/components/ChatGifs/ChatGifs.js b/qortal-ui-plugins/plugins/core/components/ChatGifs/ChatGifs.js index 3fa66eba..3d8f2757 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatGifs/ChatGifs.js +++ b/qortal-ui-plugins/plugins/core/components/ChatGifs/ChatGifs.js @@ -2,7 +2,6 @@ import {LitElement, html, css} from 'lit'; import {render} from 'lit/html.js'; import {Epml} from '../../../../epml.js'; import * as zip from '@zip.js/zip.js'; -import {saveAs} from 'file-saver'; import '@material/mwc-icon'; import ShortUniqueId from 'short-unique-id'; import {publishData} from '../../../utils/publish-image.js'; @@ -150,9 +149,7 @@ setOpenGifModal: { attribute: false } if (changedProperties && changedProperties.has('currentCollection')) { if (this.mode === 'explore') { - console.log(this.mySubscribedCollections, "subbed collections here"); const subbedCollection = this.mySubscribedCollections.find((collection) => ((collection.name === this.currentCollection.name) && (collection.identifier === this.currentCollection.identifier))); - console.log({subbedCollection}); if (subbedCollection) { this.isSubscribed = true; } else { @@ -179,7 +176,7 @@ setOpenGifModal: { attribute: false } let collectionObj = collection; try { const metaData = await parentEpml.request('apiCall', { - url: `/arbitrary/metadata/GIF_REPOSITORY/${this.myAccountName}/${collection.identifier}`, + url: `/arbitrary/metadata/GIF_REPOSITORY/${this.myAccountName}/${collection.identifier}?apiKey=${this.getApiKey()}`, }); collectionObj = { @@ -212,13 +209,19 @@ setOpenGifModal: { attribute: false } } catch (error) {} } + getApiKey() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + let apiKey = myNode.apiKey; + return apiKey; + } + async getMoreExploreGifs() { try { const getAllGifCollections = await parentEpml.request('apiCall', { type: 'api', url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=20&offset=${ this.pageNumber * 20 - }`, + }&apiKey=${this.getApiKey()}`, }); const gifCollectionWithMetaData = await this.structureCollections( @@ -239,7 +242,7 @@ setOpenGifModal: { attribute: false } try { return await parentEpml.request('apiCall', { type: 'api', - url: `/lists/gifSubscribedRepos`, + url: `/lists/gifSubscribedRepos?apiKey=${this.getApiKey()}`, }); } catch (error) {} } @@ -254,7 +257,7 @@ setOpenGifModal: { attribute: false } await parentEpml.request('apiCall', { type: 'api', method: 'POST', - url: `/lists/gifSubscribedRepos`, + url: `/lists/gifSubscribedRepos?apiKey=${this.getApiKey()}`, body: bodyToString, headers: { 'Content-Type': 'application/json', @@ -272,7 +275,7 @@ setOpenGifModal: { attribute: false } await parentEpml.request('apiCall', { type: 'api', method: 'DELETE', - url: `/lists/gifSubscribedRepos`, + url: `/lists/gifSubscribedRepos?apiKey=${this.getApiKey()}`, body: bodyToString, headers: { 'Content-Type': 'application/json', @@ -286,7 +289,7 @@ setOpenGifModal: { attribute: false } this.myAccountName = userName; if (this.myAccountName) { const getMyGifCollections = await parentEpml.request('apiCall', { - url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=0&name=${this.myAccountName}`, + url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=0&name=${this.myAccountName}&apiKey=${this.getApiKey()}`, }); const gifCollectionWithMetaData = await this.structureCollections( getMyGifCollections @@ -305,7 +308,7 @@ setOpenGifModal: { attribute: false } type: 'api', url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=20&offset=${ this.pageNumber * 20 - }`, + }&apiKey=${this.getApiKey()}`, }); const gifCollectionWithMetaData = await this.structureCollections( getAllGifCollections @@ -324,7 +327,7 @@ setOpenGifModal: { attribute: false } const identifier = splitCollection[1]; try { const data = await parentEpml.request('apiCall', { - url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=0&name=${name}&identifier=${identifier}`, + url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=0&name=${name}&identifier=${identifier}&apiKey=${this.getApiKey()}`, }); if (data.length > 0) { savedCollections.push(data[0]); @@ -346,7 +349,7 @@ setOpenGifModal: { attribute: false } try { const getNames = await parentEpml.request('apiCall', { type: 'api', - url: `/names/address/${recipient}`, + url: `/names/address/${recipient}?apiKey=${this.getApiKey()}`, }); if (Array.isArray(getNames) && getNames.length > 0) { @@ -400,7 +403,7 @@ setOpenGifModal: { attribute: false } this.isLoading = true; const userName = await this.getName(this.selectedAddress.address); const doesNameExist = await parentEpml.request('apiCall', { - url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=0&name=${userName}&identifier=${this.newCollectionName}`, + url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=0&name=${userName}&identifier=${this.newCollectionName}&apiKey=${this.getApiKey()}`, }); if (!userName) { @@ -465,6 +468,7 @@ setOpenGifModal: { attribute: false } const blobTobase = await blobToBase64(zipFileBlob); + await publishData({ registeredName: userName, file: blobTobase.split(',')[1], @@ -488,7 +492,7 @@ setOpenGifModal: { attribute: false } let myCollection = await parentEpml.request( 'apiCall', { - url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=0&name=${userName}&identifier=${this.newCollectionName}`, + url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=0&name=${userName}&identifier=${this.newCollectionName}&apiKey=${this.getApiKey()}`, } ); if (myCollection.length > 0) { @@ -509,7 +513,7 @@ setOpenGifModal: { attribute: false } }; interval = setInterval(getAnswer, 5000); }); - saveAs(zipFileBlob, 'zipfile'); + this.isLoading = false; this.setGifsLoading(false); this.mode = 'myCollection'; @@ -519,6 +523,8 @@ setOpenGifModal: { attribute: false } } catch (error) { console.log(error); parentEpml.request('showSnackBar', get('gifs.gchange12')); + this.setGifsLoading(false); + this.isLoading = false; } } @@ -552,8 +558,6 @@ setOpenGifModal: { attribute: false } } render() { - console.log(8, "chat gifs here"); - console.log('this.currentCollection', this.currentCollection); return html`
diff --git a/qortal-ui-plugins/plugins/core/components/ChatGifs/ChatGifsExplore.js b/qortal-ui-plugins/plugins/core/components/ChatGifs/ChatGifsExplore.js index 9db3f797..df825b74 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatGifs/ChatGifsExplore.js +++ b/qortal-ui-plugins/plugins/core/components/ChatGifs/ChatGifsExplore.js @@ -68,6 +68,11 @@ class ChatGifsExplore extends LitElement { this.shadowRoot.getElementById('downObserver'); this.elementObserver(); } + getApiKey() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + let apiKey = myNode.apiKey; + return apiKey; + } async searchCollections() { this.isSearched = true; @@ -75,7 +80,7 @@ class ChatGifsExplore extends LitElement { this.exploreCollections = []; this.isLoading = true; const response = await parentEpml.request('apiCall', { - url: `/arbitrary/resources/search?service=GIF_REPOSITORY&query=${this.searchCollectionName}&limit=0 + url: `/arbitrary/resources/search?service=GIF_REPOSITORY&query=${this.searchCollectionName}&limit=0&apiKey=${this.getApiKey()} `, }); await new Promise((res) => { diff --git a/qortal-ui-plugins/plugins/core/components/ChatPage.js b/qortal-ui-plugins/plugins/core/components/ChatPage.js index edb4869e..050f89da 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatPage.js +++ b/qortal-ui-plugins/plugins/core/components/ChatPage.js @@ -1386,68 +1386,14 @@ class ChatPage extends LitElement { } addGifs(gifs){ - console.log('gifs', gifs) this.gifsToBeAdded = [...this.gifsToBeAdded, ...gifs] - console.log('this.gifsToBeAdded', this.gifsToBeAdded) } setGifsLoading(props) { this.gifsLoading = props; } - async uploadGifCollection(){ - try { - function blobToBase64(blob) { - return new Promise((resolve, _) => { - const reader = new FileReader(); - reader.onloadend = () => resolve(reader.result); - reader.readAsDataURL(blob); - }); - } - const zipFileWriter = new zip.BlobWriter("application/zip"); -// Creates a TextReader object storing the text of the entry to add in the zip -// (i.e. "Hello world!"). -const helloWorldReader = new zip.TextReader("Hello world!"); - -// Creates a ZipWriter object writing data via `zipFileWriter`, adds the entry -// "hello.txt" containing the text "Hello world!" via `helloWorldReader`, and -// closes the writer. -const file = this.gifsToBeAdded[0] -const file2 = this.gifsToBeAdded[1] -const zipWriter = new zip.ZipWriter(zipFileWriter, { bufferedWrite: true }); -await zipWriter.add(file.name, new zip.BlobReader(file)); -await zipWriter.add(file2.name, new zip.BlobReader(file2)); - -await zipWriter.close(); -const zipFileBlob = await zipFileWriter.getData() -const blobTobase = await blobToBase64(zipFileBlob) -console.log({blobTobase}) -const userName = await this.getName(this.selectedAddress.address); - if (!userName) { - parentEpml.request('showSnackBar', get("chatpage.cchange27")); - this.isLoading = false; - return; - } - const id = this.uid(); - const identifier = `gif_${id}`; -await publishData({ - registeredName: userName, - file : blobTobase.split(',')[1], - service: 'GIF_REPOSITORY', - identifier: identifier, - parentEpml, - metaData: undefined, - uploadType: 'zip', - selectedAddress: this.selectedAddress, - worker: this.webWorkerImage, - isBase64: true - }) -saveAs(zipFileBlob, 'zipfile'); -console.log({zipFileBlob}) - } catch (error) { - console.log(error) - } - } + render() { return html` @@ -1502,7 +1448,7 @@ console.log({zipFileBlob}) this.setGifsLoading(val)} .sendMessage=${(val) => this._sendMessage(val)} .setOpenGifModal=${(val)=> this.setOpenGifModal(val)}> @@ -2069,8 +2015,8 @@ console.log({zipFileBlob}) if(this.webWorker){ this.webWorker.terminate(); } - if(this.webWorkerImage){ - this.webWorkerImage.terminate(); + if(this.webWorkerFile){ + this.webWorkerFile.terminate(); } if(this.editor){ this.editor.destroy() diff --git a/qortal-ui-plugins/plugins/core/components/ChatScroller.js b/qortal-ui-plugins/plugins/core/components/ChatScroller.js index 64a4d0ee..a6ba4105 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatScroller.js +++ b/qortal-ui-plugins/plugins/core/components/ChatScroller.js @@ -80,7 +80,6 @@ class ChatScroller extends LitElement { } render() { - console.log(5, "chat scroller here"); let formattedMessages = this.messages.reduce((messageArray, message, index) => { const lastGroupedMessage = messageArray[messageArray.length - 1]; let timestamp; diff --git a/qortal-ui-plugins/plugins/core/components/ChatTextEditor.js b/qortal-ui-plugins/plugins/core/components/ChatTextEditor.js index 9ed0fe25..bfb929d0 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatTextEditor.js +++ b/qortal-ui-plugins/plugins/core/components/ChatTextEditor.js @@ -455,7 +455,6 @@ mwc-checkbox::shadow .mdc-checkbox::after, mwc-checkbox::shadow .mdc-checkbox::b >${translate('chatpage.cchange69')} { - console.log(e.target.checked) if(e.target.checked){ window.parent.reduxStore.dispatch( window.parent.reduxAction.removeAutoLoadImageChat(this.chatId)) return diff --git a/qortal-ui-plugins/plugins/core/components/ImageComponent.js b/qortal-ui-plugins/plugins/core/components/ImageComponent.js index 78f37603..b113d75a 100644 --- a/qortal-ui-plugins/plugins/core/components/ImageComponent.js +++ b/qortal-ui-plugins/plugins/core/components/ImageComponent.js @@ -52,6 +52,11 @@ constructor() { 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++; @@ -62,7 +67,7 @@ async _fetchImage() { }, 1000) }); try { - const response = await fetch(this.gif.url); + const response = await fetch(this.gif.url + `&apiKey=${this.getApiKey()}`); const data = await response.json(); console.log({data}); if (data.ok) {