mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-03-27 15:55:55 +00:00
ability to save and read private data
This commit is contained in:
parent
58bf4aa7c9
commit
fbe8b6aecb
@ -237,9 +237,11 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
changedProperties.has('editContent') &&
|
changedProperties.has('editContent') &&
|
||||||
this.editContent
|
this.editContent
|
||||||
) {
|
) {
|
||||||
this.bio = this.editContent.bio ?? '';
|
const {bio, tagline, wallets, customData} = this.editContent
|
||||||
this.tagline = this.editContent.tagline ?? '';
|
this.bio = bio ?? '';
|
||||||
this.wallets = this.editContent.wallets ?? {};
|
this.tagline = tagline ?? '';
|
||||||
|
this.wallets = wallets ?? {};
|
||||||
|
this.customData = {...customData}
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,6 +355,7 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
tagline: this.tagline,
|
tagline: this.tagline,
|
||||||
bio: this.bio,
|
bio: this.bio,
|
||||||
wallets: this.wallets,
|
wallets: this.wallets,
|
||||||
|
customData: this.customData
|
||||||
};
|
};
|
||||||
await this.onSubmit(data);
|
await this.onSubmit(data);
|
||||||
this.setIsOpen(false);
|
this.setIsOpen(false);
|
||||||
@ -378,6 +381,22 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
const copyObj = {...this.customData}
|
const copyObj = {...this.customData}
|
||||||
copyObj[this.newCustomDataKey] = this.newCustomDataField
|
copyObj[this.newCustomDataKey] = this.newCustomDataField
|
||||||
this.customData = copyObj
|
this.customData = copyObj
|
||||||
|
this.newCustomDataKey = ""
|
||||||
|
this.newCustomDataField = {};
|
||||||
|
this.newFieldName = ''
|
||||||
|
this.isOpenCustomDataModal = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCustomData(key, data){
|
||||||
|
this.isOpenCustomDataModal = true
|
||||||
|
this.newCustomDataField = data
|
||||||
|
this.newCustomDataKey = key
|
||||||
|
|
||||||
|
}
|
||||||
|
removeCustomData(key){
|
||||||
|
const copyObj = {...this.customData}
|
||||||
|
delete copyObj[key]
|
||||||
|
this.customData = copyObj
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -472,6 +491,40 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
|
|||||||
`;
|
`;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
<div style="display: flex;flex-direction: column;">
|
||||||
|
${Object.keys(this.customData).map((key) => {
|
||||||
|
return html`
|
||||||
|
<div
|
||||||
|
style="display:flex;justify-content:center;flex-direction:column;gap:25px"
|
||||||
|
>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style="display:flex;gap:15px;align-items:center"
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
|
||||||
|
style="color: var(--black);font-size:16px"
|
||||||
|
>
|
||||||
|
${key}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<mwc-icon
|
||||||
|
@click=${() =>
|
||||||
|
this.updateCustomData(key,this.customData[key])}
|
||||||
|
style="color:var(--black);cursor:pointer"
|
||||||
|
>edit</mwc-icon
|
||||||
|
>
|
||||||
|
<mwc-icon
|
||||||
|
@click=${() =>
|
||||||
|
this.removeCustomData(key)}
|
||||||
|
style="color:var(--black);cursor:pointer"
|
||||||
|
>remove</mwc-icon
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
style="display:flex;justify-content:space-between;align-items:center;margin-top:20px"
|
style="display:flex;justify-content:space-between;align-items:center;margin-top:20px"
|
||||||
|
@ -198,8 +198,34 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
async setValues(response, resource) {
|
async setValues(response, resource) {
|
||||||
console.log('hello', response)
|
console.log('hello', response)
|
||||||
|
|
||||||
if(response){
|
if(response){
|
||||||
this.profileData = 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);
|
||||||
|
if(decryptedDataToBase64 && !decryptedDataToBase64.error){
|
||||||
|
customData[key] = decryptedDataToBase64;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log({error})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.profileData = {
|
||||||
|
...response,
|
||||||
|
customData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,18 +341,18 @@ class ProfileQdn extends connect(store)(LitElement) {
|
|||||||
const getArbitraryFee = await this.getArbitraryFee();
|
const getArbitraryFee = await this.getArbitraryFee();
|
||||||
const feeAmount = getArbitraryFee.fee;
|
const feeAmount = getArbitraryFee.fee;
|
||||||
|
|
||||||
let newObject = {};
|
let newObject = {...data};
|
||||||
|
|
||||||
for (const key of Object.keys(data)) {
|
for (const key of Object.keys(newObject.customData || {})) {
|
||||||
if (key.includes('-private')) {
|
if (key.includes('-private')) {
|
||||||
const toBase64 = await objectToBase64(newObject);
|
const toBase64 = await objectToBase64(newObject.customData[key]);
|
||||||
const encryptedData = encryptDataGroup({
|
const encryptedData = encryptDataGroup({
|
||||||
data64: toBase64,
|
data64: toBase64,
|
||||||
publicKeys: [],
|
publicKeys: [],
|
||||||
});
|
});
|
||||||
newObject[key] = encryptedData;
|
newObject['customData'][key] = encryptedData;
|
||||||
} else {
|
} else {
|
||||||
newObject[key] = data[key];
|
newObject['customData'][key] = data[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user