mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-04-24 20:07:51 +00:00
fix apiKey error
This commit is contained in:
parent
f925f8bf43
commit
035c3c5e6d
@ -2,7 +2,6 @@ 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 * as zip from '@zip.js/zip.js';
|
import * as zip from '@zip.js/zip.js';
|
||||||
import {saveAs} from 'file-saver';
|
|
||||||
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';
|
||||||
@ -150,9 +149,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
|
|
||||||
if (changedProperties && changedProperties.has('currentCollection')) {
|
if (changedProperties && changedProperties.has('currentCollection')) {
|
||||||
if (this.mode === 'explore') {
|
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)));
|
const subbedCollection = this.mySubscribedCollections.find((collection) => ((collection.name === this.currentCollection.name) && (collection.identifier === this.currentCollection.identifier)));
|
||||||
console.log({subbedCollection});
|
|
||||||
if (subbedCollection) {
|
if (subbedCollection) {
|
||||||
this.isSubscribed = true;
|
this.isSubscribed = true;
|
||||||
} else {
|
} else {
|
||||||
@ -179,7 +176,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
let collectionObj = collection;
|
let collectionObj = collection;
|
||||||
try {
|
try {
|
||||||
const metaData = await parentEpml.request('apiCall', {
|
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 = {
|
collectionObj = {
|
||||||
@ -212,13 +209,19 @@ setOpenGifModal: { attribute: false }
|
|||||||
} catch (error) {}
|
} 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() {
|
async getMoreExploreGifs() {
|
||||||
try {
|
try {
|
||||||
const getAllGifCollections = await parentEpml.request('apiCall', {
|
const getAllGifCollections = await parentEpml.request('apiCall', {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=20&offset=${
|
url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=20&offset=${
|
||||||
this.pageNumber * 20
|
this.pageNumber * 20
|
||||||
}`,
|
}&apiKey=${this.getApiKey()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const gifCollectionWithMetaData = await this.structureCollections(
|
const gifCollectionWithMetaData = await this.structureCollections(
|
||||||
@ -239,7 +242,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
try {
|
try {
|
||||||
return await parentEpml.request('apiCall', {
|
return await parentEpml.request('apiCall', {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
url: `/lists/gifSubscribedRepos`,
|
url: `/lists/gifSubscribedRepos?apiKey=${this.getApiKey()}`,
|
||||||
});
|
});
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
@ -254,7 +257,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
await parentEpml.request('apiCall', {
|
await parentEpml.request('apiCall', {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/lists/gifSubscribedRepos`,
|
url: `/lists/gifSubscribedRepos?apiKey=${this.getApiKey()}`,
|
||||||
body: bodyToString,
|
body: bodyToString,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -272,7 +275,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
await parentEpml.request('apiCall', {
|
await parentEpml.request('apiCall', {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/lists/gifSubscribedRepos`,
|
url: `/lists/gifSubscribedRepos?apiKey=${this.getApiKey()}`,
|
||||||
body: bodyToString,
|
body: bodyToString,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -286,7 +289,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
this.myAccountName = userName;
|
this.myAccountName = userName;
|
||||||
if (this.myAccountName) {
|
if (this.myAccountName) {
|
||||||
const getMyGifCollections = await parentEpml.request('apiCall', {
|
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(
|
const gifCollectionWithMetaData = await this.structureCollections(
|
||||||
getMyGifCollections
|
getMyGifCollections
|
||||||
@ -305,7 +308,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
type: 'api',
|
type: 'api',
|
||||||
url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=20&offset=${
|
url: `/arbitrary/resources?service=GIF_REPOSITORY&limit=20&offset=${
|
||||||
this.pageNumber * 20
|
this.pageNumber * 20
|
||||||
}`,
|
}&apiKey=${this.getApiKey()}`,
|
||||||
});
|
});
|
||||||
const gifCollectionWithMetaData = await this.structureCollections(
|
const gifCollectionWithMetaData = await this.structureCollections(
|
||||||
getAllGifCollections
|
getAllGifCollections
|
||||||
@ -324,7 +327,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
const identifier = splitCollection[1];
|
const identifier = splitCollection[1];
|
||||||
try {
|
try {
|
||||||
const data = await parentEpml.request('apiCall', {
|
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) {
|
if (data.length > 0) {
|
||||||
savedCollections.push(data[0]);
|
savedCollections.push(data[0]);
|
||||||
@ -346,7 +349,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
try {
|
try {
|
||||||
const getNames = await parentEpml.request('apiCall', {
|
const getNames = await parentEpml.request('apiCall', {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
url: `/names/address/${recipient}`,
|
url: `/names/address/${recipient}?apiKey=${this.getApiKey()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Array.isArray(getNames) && getNames.length > 0) {
|
if (Array.isArray(getNames) && getNames.length > 0) {
|
||||||
@ -400,7 +403,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
const userName = await this.getName(this.selectedAddress.address);
|
const userName = await this.getName(this.selectedAddress.address);
|
||||||
const doesNameExist = await parentEpml.request('apiCall', {
|
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) {
|
if (!userName) {
|
||||||
@ -465,6 +468,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
|
|
||||||
const blobTobase = await blobToBase64(zipFileBlob);
|
const blobTobase = await blobToBase64(zipFileBlob);
|
||||||
|
|
||||||
|
|
||||||
await publishData({
|
await publishData({
|
||||||
registeredName: userName,
|
registeredName: userName,
|
||||||
file: blobTobase.split(',')[1],
|
file: blobTobase.split(',')[1],
|
||||||
@ -488,7 +492,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
let myCollection = await parentEpml.request(
|
let myCollection = await parentEpml.request(
|
||||||
'apiCall',
|
'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) {
|
if (myCollection.length > 0) {
|
||||||
@ -509,7 +513,7 @@ setOpenGifModal: { attribute: false }
|
|||||||
};
|
};
|
||||||
interval = setInterval(getAnswer, 5000);
|
interval = setInterval(getAnswer, 5000);
|
||||||
});
|
});
|
||||||
saveAs(zipFileBlob, 'zipfile');
|
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.setGifsLoading(false);
|
this.setGifsLoading(false);
|
||||||
this.mode = 'myCollection';
|
this.mode = 'myCollection';
|
||||||
@ -519,6 +523,8 @@ setOpenGifModal: { attribute: false }
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
parentEpml.request('showSnackBar', get('gifs.gchange12'));
|
parentEpml.request('showSnackBar', get('gifs.gchange12'));
|
||||||
|
this.setGifsLoading(false);
|
||||||
|
this.isLoading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,8 +558,6 @@ setOpenGifModal: { attribute: false }
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(8, "chat gifs here");
|
|
||||||
console.log('this.currentCollection', this.currentCollection);
|
|
||||||
return html`
|
return html`
|
||||||
<div class="gifs-container">
|
<div class="gifs-container">
|
||||||
<div class="gif-explorer-container">
|
<div class="gif-explorer-container">
|
||||||
|
@ -68,6 +68,11 @@ class ChatGifsExplore extends LitElement {
|
|||||||
this.shadowRoot.getElementById('downObserver');
|
this.shadowRoot.getElementById('downObserver');
|
||||||
this.elementObserver();
|
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() {
|
async searchCollections() {
|
||||||
this.isSearched = true;
|
this.isSearched = true;
|
||||||
@ -75,7 +80,7 @@ class ChatGifsExplore extends LitElement {
|
|||||||
this.exploreCollections = [];
|
this.exploreCollections = [];
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
const response = await parentEpml.request('apiCall', {
|
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) => {
|
await new Promise((res) => {
|
||||||
|
@ -1386,68 +1386,14 @@ class ChatPage extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addGifs(gifs){
|
addGifs(gifs){
|
||||||
console.log('gifs', gifs)
|
|
||||||
this.gifsToBeAdded = [...this.gifsToBeAdded, ...gifs]
|
this.gifsToBeAdded = [...this.gifsToBeAdded, ...gifs]
|
||||||
console.log('this.gifsToBeAdded', this.gifsToBeAdded)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setGifsLoading(props) {
|
setGifsLoading(props) {
|
||||||
this.gifsLoading = 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() {
|
render() {
|
||||||
return html`
|
return html`
|
||||||
@ -1502,7 +1448,7 @@ console.log({zipFileBlob})
|
|||||||
<chat-gifs
|
<chat-gifs
|
||||||
class="chat-gifs"
|
class="chat-gifs"
|
||||||
style=${this.openGifModal ? "display: flex;" : "display: none;"}
|
style=${this.openGifModal ? "display: flex;" : "display: none;"}
|
||||||
.webWorkerImage=${this.webWorkerImage}
|
.webWorkerImage=${this.webWorkerFile}
|
||||||
.setGifsLoading=${(val) => this.setGifsLoading(val)}
|
.setGifsLoading=${(val) => this.setGifsLoading(val)}
|
||||||
.sendMessage=${(val) => this._sendMessage(val)}
|
.sendMessage=${(val) => this._sendMessage(val)}
|
||||||
.setOpenGifModal=${(val)=> this.setOpenGifModal(val)}>
|
.setOpenGifModal=${(val)=> this.setOpenGifModal(val)}>
|
||||||
@ -2069,8 +2015,8 @@ console.log({zipFileBlob})
|
|||||||
if(this.webWorker){
|
if(this.webWorker){
|
||||||
this.webWorker.terminate();
|
this.webWorker.terminate();
|
||||||
}
|
}
|
||||||
if(this.webWorkerImage){
|
if(this.webWorkerFile){
|
||||||
this.webWorkerImage.terminate();
|
this.webWorkerFile.terminate();
|
||||||
}
|
}
|
||||||
if(this.editor){
|
if(this.editor){
|
||||||
this.editor.destroy()
|
this.editor.destroy()
|
||||||
|
@ -80,7 +80,6 @@ class ChatScroller extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(5, "chat scroller here");
|
|
||||||
let formattedMessages = this.messages.reduce((messageArray, message, index) => {
|
let formattedMessages = this.messages.reduce((messageArray, message, index) => {
|
||||||
const lastGroupedMessage = messageArray[messageArray.length - 1];
|
const lastGroupedMessage = messageArray[messageArray.length - 1];
|
||||||
let timestamp;
|
let timestamp;
|
||||||
|
@ -455,7 +455,6 @@ mwc-checkbox::shadow .mdc-checkbox::after, mwc-checkbox::shadow .mdc-checkbox::b
|
|||||||
>${translate('chatpage.cchange69')}</label>
|
>${translate('chatpage.cchange69')}</label>
|
||||||
|
|
||||||
<mwc-checkbox style="margin-right: -15px;" id="qChatShowAutoMsg" @click=${e => {
|
<mwc-checkbox style="margin-right: -15px;" id="qChatShowAutoMsg" @click=${e => {
|
||||||
console.log(e.target.checked)
|
|
||||||
if(e.target.checked){
|
if(e.target.checked){
|
||||||
window.parent.reduxStore.dispatch( window.parent.reduxAction.removeAutoLoadImageChat(this.chatId))
|
window.parent.reduxStore.dispatch( window.parent.reduxAction.removeAutoLoadImageChat(this.chatId))
|
||||||
return
|
return
|
||||||
|
@ -52,6 +52,11 @@ constructor() {
|
|||||||
this.attempts = 0;
|
this.attempts = 0;
|
||||||
this.maxAttempts = 5;
|
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() {
|
async _fetchImage() {
|
||||||
this.attempts++;
|
this.attempts++;
|
||||||
@ -62,7 +67,7 @@ async _fetchImage() {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const response = await fetch(this.gif.url);
|
const response = await fetch(this.gif.url + `&apiKey=${this.getApiKey()}`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log({data});
|
console.log({data});
|
||||||
if (data.ok) {
|
if (data.ok) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user