mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-12 02:05:51 +00:00
final changes
This commit is contained in:
parent
55b9e8d343
commit
cbd82d5e7f
@ -1236,6 +1236,7 @@
|
|||||||
"profile17": "Unable to fetch profile",
|
"profile17": "Unable to fetch profile",
|
||||||
"profile18": "Open profile",
|
"profile18": "Open profile",
|
||||||
"profile19": "Cannot fetch profile",
|
"profile19": "Cannot fetch profile",
|
||||||
"profile20": "Register name"
|
"profile20": "Register name",
|
||||||
|
"profile21": "Insert address from UI"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ import {
|
|||||||
} from 'lit-translate';
|
} from 'lit-translate';
|
||||||
import '@material/mwc-button';
|
import '@material/mwc-button';
|
||||||
import '@material/mwc-icon';
|
import '@material/mwc-icon';
|
||||||
|
import '@vaadin/tooltip';
|
||||||
import '@material/mwc-dialog';
|
import '@material/mwc-dialog';
|
||||||
import '@material/mwc-checkbox';
|
import '@material/mwc-checkbox';
|
||||||
import { connect } from 'pwa-helpers';
|
import { connect } from 'pwa-helpers';
|
||||||
@ -244,7 +245,16 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
const {bio, tagline, wallets, customData} = this.editContent
|
const {bio, tagline, wallets, customData} = this.editContent
|
||||||
this.bio = bio ?? '';
|
this.bio = bio ?? '';
|
||||||
this.tagline = tagline ?? '';
|
this.tagline = tagline ?? '';
|
||||||
this.wallets = wallets ?? {};
|
let formWallets = {...this.wallets}
|
||||||
|
if(wallets && Object.keys(wallets).length){
|
||||||
|
Object.keys(formWallets).forEach((key)=> {
|
||||||
|
if(wallets[key]){
|
||||||
|
formWallets[key] = wallets[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.wallets = formWallets
|
||||||
|
|
||||||
this.customData = {...customData}
|
this.customData = {...customData}
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
@ -253,7 +263,6 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
changedProperties.has('qortalRequestCustomData') &&
|
changedProperties.has('qortalRequestCustomData') &&
|
||||||
this.qortalRequestCustomData
|
this.qortalRequestCustomData
|
||||||
) {
|
) {
|
||||||
console.log('this.qortalRequestCustomData', this.qortalRequestCustomData)
|
|
||||||
this.isOpenCustomDataModal = true
|
this.isOpenCustomDataModal = true
|
||||||
this.newCustomDataField = {...this.qortalRequestCustomData.payload.customData}
|
this.newCustomDataField = {...this.qortalRequestCustomData.payload.customData}
|
||||||
this.newCustomDataKey = this.qortalRequestCustomData.property
|
this.newCustomDataKey = this.qortalRequestCustomData.property
|
||||||
@ -273,10 +282,8 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fetchWalletAddress(coin) {
|
async fetchWalletAddress(coin) {
|
||||||
console.log({ coin });
|
|
||||||
switch (coin) {
|
switch (coin) {
|
||||||
case 'arrr':
|
case 'arrr':
|
||||||
console.log('arrr');
|
|
||||||
const arrrWalletName = `${coin}Wallet`;
|
const arrrWalletName = `${coin}Wallet`;
|
||||||
|
|
||||||
const res2 = await parentEpml.request('apiCall', {
|
const res2 = await parentEpml.request('apiCall', {
|
||||||
@ -352,7 +359,6 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
clearFields() {
|
clearFields() {
|
||||||
this.bio = '';
|
this.bio = '';
|
||||||
this.tagline = '';
|
this.tagline = '';
|
||||||
this.wallets = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fillAddress(coin) {
|
fillAddress(coin) {
|
||||||
@ -420,7 +426,6 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log('modal');
|
|
||||||
return html`
|
return html`
|
||||||
<div class="modal-overlay ${this.isOpen ? '' : 'hidden'}">
|
<div class="modal-overlay ${this.isOpen ? '' : 'hidden'}">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -499,11 +504,20 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<mwc-icon
|
<mwc-icon
|
||||||
|
id=${`${key}-upload`}
|
||||||
@click=${() =>
|
@click=${() =>
|
||||||
this.fillAddress(key)}
|
this.fillAddress(key)}
|
||||||
style="color:var(--black);cursor:pointer"
|
style="color:var(--black);cursor:pointer"
|
||||||
>upload_2</mwc-icon
|
>upload_2</mwc-icon
|
||||||
>
|
>
|
||||||
|
<vaadin-tooltip
|
||||||
|
for=${`${key}-upload`}
|
||||||
|
position="bottom"
|
||||||
|
hover-delay=${200}
|
||||||
|
hide-delay=${1}
|
||||||
|
text=${translate('profile.profile21')}
|
||||||
|
>
|
||||||
|
</vaadin-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -669,7 +683,7 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<div style="height:15px"></div>
|
<div style="height:15px"></div>
|
||||||
<div style="width:100%;display:flex;justify-content:center;gap:10px">
|
<div style="width:100%;display:flex;justify-content:center;gap:10px;margin-top:30px">
|
||||||
<input
|
<input
|
||||||
|
|
||||||
placeholder=${translate('profile.profile12')}
|
placeholder=${translate('profile.profile12')}
|
||||||
|
@ -327,20 +327,16 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setValues(response, resource) {
|
async setValues(response, resource) {
|
||||||
console.log('hello', response);
|
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
let data = { ...response };
|
let data = { ...response };
|
||||||
let customData = {};
|
let customData = {};
|
||||||
for (const key of Object.keys(data.customData || {})) {
|
for (const key of Object.keys(data.customData || {})) {
|
||||||
if (key.includes('-private')) {
|
if (key.includes('-private')) {
|
||||||
try {
|
try {
|
||||||
console.log('key', data.customData[key]);
|
|
||||||
const decryptedData = decryptGroupData(
|
const decryptedData = decryptGroupData(
|
||||||
data.customData[key]
|
data.customData[key]
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log({ decryptedData });
|
|
||||||
if (decryptedData && !decryptedData.error) {
|
if (decryptedData && !decryptedData.error) {
|
||||||
const decryptedDataToBase64 =
|
const decryptedDataToBase64 =
|
||||||
uint8ArrayToObject(decryptedData);
|
uint8ArrayToObject(decryptedData);
|
||||||
@ -368,19 +364,14 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getVisitingProfile(name) {
|
async getVisitingProfile(name) {
|
||||||
console.log('name2', name)
|
|
||||||
try {
|
try {
|
||||||
// this.error = '';
|
|
||||||
this.isLoadingVisitingProfile = true
|
this.isLoadingVisitingProfile = true
|
||||||
this.nameVisiting = name
|
this.nameVisiting = name
|
||||||
this.imageUrl = `${this.nodeUrl}/arbitrary/THUMBNAIL/${name}/qortal_avatar?async=true&apiKey=${this.myNode.apiKey}`;
|
|
||||||
const url = `${this.nodeUrl}/arbitrary/resources/search?service=DOCUMENT&identifier=qortal_profile&name=${name}&prefix=true&exactmatchnames=true&excludeblocked=true&limit=20`;
|
const url = `${this.nodeUrl}/arbitrary/resources/search?service=DOCUMENT&identifier=qortal_profile&name=${name}&prefix=true&exactmatchnames=true&excludeblocked=true&limit=20`;
|
||||||
const res = await fetch(url);
|
const res = await fetch(url);
|
||||||
let data = '';
|
let data = '';
|
||||||
try {
|
try {
|
||||||
console.log({ res });
|
|
||||||
data = await res.json();
|
data = await res.json();
|
||||||
console.log({ data });
|
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
data = data.filter(
|
data = data.filter(
|
||||||
(item) => item.identifier === 'qortal_profile'
|
(item) => item.identifier === 'qortal_profile'
|
||||||
@ -391,7 +382,6 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
const dataItem = data[0];
|
const dataItem = data[0];
|
||||||
try {
|
try {
|
||||||
const response = await this.getRawData(dataItem);
|
const response = await this.getRawData(dataItem);
|
||||||
console.log({ response });
|
|
||||||
if (response.wallets) {
|
if (response.wallets) {
|
||||||
this.profileDataVisiting = response
|
this.profileDataVisiting = response
|
||||||
// this.setValues(response, dataItem);
|
// this.setValues(response, dataItem);
|
||||||
@ -425,7 +415,6 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
async getProfile() {
|
async getProfile() {
|
||||||
try {
|
try {
|
||||||
console.log('hello start')
|
|
||||||
this.error = ''
|
this.error = ''
|
||||||
const arbFee = await this.getArbitraryFee();
|
const arbFee = await this.getArbitraryFee();
|
||||||
this.fee = arbFee;
|
this.fee = arbFee;
|
||||||
@ -442,20 +431,16 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
if (!nameObject) {
|
if (!nameObject) {
|
||||||
this.name = null;
|
this.name = null;
|
||||||
this.error = 'no name'
|
this.error = 'no name'
|
||||||
console.log('hello', this.error)
|
|
||||||
throw new Error('no name');
|
throw new Error('no name');
|
||||||
}
|
}
|
||||||
this.hasName = true
|
this.hasName = true
|
||||||
const name = nameObject.name;
|
const name = nameObject.name;
|
||||||
this.imageUrl = `${this.nodeUrl}/arbitrary/THUMBNAIL/${name}/qortal_avatar?async=true&apiKey=${this.myNode.apiKey}`;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
const url = `${this.nodeUrl}/arbitrary/resources/search?service=DOCUMENT&identifier=qortal_profile&name=${name}&prefix=true&exactmatchnames=true&excludeblocked=true&limit=20`;
|
const url = `${this.nodeUrl}/arbitrary/resources/search?service=DOCUMENT&identifier=qortal_profile&name=${name}&prefix=true&exactmatchnames=true&excludeblocked=true&limit=20`;
|
||||||
const res = await fetch(url);
|
const res = await fetch(url);
|
||||||
let data = '';
|
let data = '';
|
||||||
try {
|
try {
|
||||||
console.log({ res });
|
|
||||||
data = await res.json();
|
data = await res.json();
|
||||||
console.log({ data });
|
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
data = data.filter(
|
data = data.filter(
|
||||||
(item) => item.identifier === 'qortal_profile'
|
(item) => item.identifier === 'qortal_profile'
|
||||||
@ -466,14 +451,12 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
const dataItem = data[0];
|
const dataItem = data[0];
|
||||||
try {
|
try {
|
||||||
const response = await this.getRawData(dataItem);
|
const response = await this.getRawData(dataItem);
|
||||||
console.log({ response });
|
|
||||||
if (response.wallets) {
|
if (response.wallets) {
|
||||||
this.setValues(response, dataItem);
|
this.setValues(response, dataItem);
|
||||||
} else {
|
} else {
|
||||||
this.error = 'Cannot get saved user settings';
|
this.error = 'Cannot get saved user settings';
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log({ error });
|
|
||||||
this.error = 'Cannot get saved user settings';
|
this.error = 'Cannot get saved user settings';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -483,7 +466,6 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
this.error = 'Unable to perform query';
|
this.error = 'Unable to perform query';
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log({ error });
|
|
||||||
data = {
|
data = {
|
||||||
error: 'No resource found',
|
error: 'No resource found',
|
||||||
};
|
};
|
||||||
@ -539,7 +521,6 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
async saveToQdn(data) {
|
async saveToQdn(data) {
|
||||||
try {
|
try {
|
||||||
console.log({ data });
|
|
||||||
this.isSaving = true;
|
this.isSaving = true;
|
||||||
if (this.resourceExists === true && this.error)
|
if (this.resourceExists === true && this.error)
|
||||||
throw new Error('Unable to save');
|
throw new Error('Unable to save');
|
||||||
@ -576,12 +557,7 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
newObject['customData'][key] = newObject.customData[key];
|
newObject['customData'][key] = newObject.customData[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log({ newObject });
|
|
||||||
const newObjectToBase64 = await objectToBase64(newObject);
|
const newObjectToBase64 = await objectToBase64(newObject);
|
||||||
// const encryptedData = encryptDataGroup({
|
|
||||||
// data64: newObjectToBase64,
|
|
||||||
// publicKeys: [],
|
|
||||||
// });
|
|
||||||
|
|
||||||
const worker = new WebWorker2();
|
const worker = new WebWorker2();
|
||||||
try {
|
try {
|
||||||
@ -605,9 +581,7 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
this.profileData = data;
|
this.profileData = data;
|
||||||
store.dispatch(setProfileData(data));
|
store.dispatch(setProfileData(data));
|
||||||
|
|
||||||
// this.setValues(newObject, {
|
|
||||||
// updated: Date.now(),
|
|
||||||
// });
|
|
||||||
worker.terminate();
|
worker.terminate();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
worker.terminate();
|
worker.terminate();
|
||||||
@ -643,14 +617,7 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
detail: detail,
|
detail: detail,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
try {
|
|
||||||
console.log(
|
|
||||||
'hello100',
|
|
||||||
iframeWindow.document.querySelector('multi-wallet')
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
console.log({ error });
|
|
||||||
}
|
|
||||||
iframeWindow.dispatchEvent(customEvent);
|
iframeWindow.dispatchEvent(customEvent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -670,7 +637,6 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
this.editContent = {
|
this.editContent = {
|
||||||
...(this.profileData || {}),
|
...(this.profileData || {}),
|
||||||
};
|
};
|
||||||
console.log({ detail });
|
|
||||||
if (detail.payload.customData) {
|
if (detail.payload.customData) {
|
||||||
this.qortalRequestCustomData = detail;
|
this.qortalRequestCustomData = detail;
|
||||||
}
|
}
|
||||||
@ -702,7 +668,6 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
uniqueId: detail.uniqueId,
|
uniqueId: detail.uniqueId,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log({ error });
|
|
||||||
this.sendBackEvent({
|
this.sendBackEvent({
|
||||||
response: 'error',
|
response: 'error',
|
||||||
uniqueId: detail.uniqueId,
|
uniqueId: detail.uniqueId,
|
||||||
@ -712,10 +677,7 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
_handleOpenVisiting(event){
|
_handleOpenVisiting(event){
|
||||||
try {
|
try {
|
||||||
console.log({event})
|
|
||||||
const name = event.detail;
|
const name = event.detail;
|
||||||
console.log({name})
|
|
||||||
// if(!name) return
|
|
||||||
this.getVisitingProfile(name)
|
this.getVisitingProfile(name)
|
||||||
this.dialogOpenedProfile = true
|
this.dialogOpenedProfile = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -764,6 +726,8 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
avatarFullImage() {
|
avatarFullImage() {
|
||||||
|
this.imageUrl = `${this.nodeUrl}/arbitrary/THUMBNAIL/${this.nameVisiting}/qortal_avatar?async=true&apiKey=${this.myNode.apiKey}`;
|
||||||
|
|
||||||
return html`<img
|
return html`<img
|
||||||
class="round-fullinfo"
|
class="round-fullinfo"
|
||||||
src="${this.imageUrl}"
|
src="${this.imageUrl}"
|
||||||
@ -802,7 +766,6 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
console.log('sup profile2', this.error, this.profileDataVisiting, this.dialogOpenedProfile );
|
|
||||||
return html`
|
return html`
|
||||||
${this.isSaving ||
|
${this.isSaving ||
|
||||||
(!this.error && this.resourceExists === undefined)
|
(!this.error && this.resourceExists === undefined)
|
||||||
|
@ -67,7 +67,6 @@ export class ChatGroupsModal extends LitElement {
|
|||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log('hello')
|
|
||||||
return html`
|
return html`
|
||||||
|
|
||||||
<mwc-dialog
|
<mwc-dialog
|
||||||
|
@ -2127,7 +2127,6 @@ class WebBrowser extends LitElement {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'SET_PROFILE_DATA': {
|
case 'SET_PROFILE_DATA': {
|
||||||
const defaultProperties = ['tagline', 'bio', 'wallets']
|
|
||||||
const requiredFields = ['property', 'data'];
|
const requiredFields = ['property', 'data'];
|
||||||
const missingFields = [];
|
const missingFields = [];
|
||||||
|
|
||||||
@ -2148,10 +2147,6 @@ class WebBrowser extends LitElement {
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// const profileData = window.parent.reduxStore.getState().app.profileData
|
|
||||||
// if (!profileData) {
|
|
||||||
// throw new Error('User does not have a profile')
|
|
||||||
// }
|
|
||||||
const property = data.property
|
const property = data.property
|
||||||
const payload = data.data
|
const payload = data.data
|
||||||
const uniqueId = this.uid.rnd()
|
const uniqueId = this.uid.rnd()
|
||||||
@ -2184,7 +2179,6 @@ class WebBrowser extends LitElement {
|
|||||||
// Handle the data from the event, if any
|
// Handle the data from the event, if any
|
||||||
const responseData = event.detail;
|
const responseData = event.detail;
|
||||||
if(responseData && responseData.uniqueId !== uniqueId) return
|
if(responseData && responseData.uniqueId !== uniqueId) return
|
||||||
console.log({responseData})
|
|
||||||
// Clean up by removing the event listener once we've received the response
|
// Clean up by removing the event listener once we've received the response
|
||||||
window.removeEventListener('qortal-request-set-profile-data-response', handleResponseEvent);
|
window.removeEventListener('qortal-request-set-profile-data-response', handleResponseEvent);
|
||||||
|
|
||||||
@ -2199,7 +2193,6 @@ class WebBrowser extends LitElement {
|
|||||||
window.addEventListener('qortal-request-set-profile-data-response', handleResponseEvent);
|
window.addEventListener('qortal-request-set-profile-data-response', handleResponseEvent);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log({res})
|
|
||||||
response = JSON.stringify(res);
|
response = JSON.stringify(res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const obj = {};
|
const obj = {};
|
||||||
@ -2212,6 +2205,41 @@ class WebBrowser extends LitElement {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'OPEN_PROFILE': {
|
||||||
|
const requiredFields = ['name'];
|
||||||
|
const missingFields = [];
|
||||||
|
|
||||||
|
requiredFields.forEach((field) => {
|
||||||
|
if (!data[field] && data[field] !== 0) {
|
||||||
|
missingFields.push(field);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (missingFields.length > 0) {
|
||||||
|
const missingFieldsString = missingFields.join(', ');
|
||||||
|
const errorMsg = `Missing fields: ${missingFieldsString}`
|
||||||
|
let data = {};
|
||||||
|
data['error'] = errorMsg;
|
||||||
|
response = JSON.stringify(data);
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
const customEvent = new CustomEvent('open-visiting-profile', {
|
||||||
|
detail: data.name
|
||||||
|
});
|
||||||
|
window.parent.dispatchEvent(customEvent);
|
||||||
|
response = JSON.stringify(true);
|
||||||
|
} catch (error) {
|
||||||
|
const obj = {};
|
||||||
|
const errorMsg = error.message || 'Failed to open profile';
|
||||||
|
obj['error'] = errorMsg;
|
||||||
|
response = JSON.stringify(obj);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
case actions.GET_WALLET_BALANCE: {
|
case actions.GET_WALLET_BALANCE: {
|
||||||
const requiredFields = ['coin'];
|
const requiredFields = ['coin'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user