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