Merge pull request #30 from franze6/DID-6

Change methods in store
This commit is contained in:
DuCay
2022-07-06 18:52:22 +03:00
committed by GitHub
3 changed files with 12 additions and 19 deletions

View File

@@ -14,7 +14,7 @@ const Onboarding4 = observer(()=>{
if(checkBoxes.find(item=>item.checked===false)) {
return
} else {
registrationStore.pushNewAccount()
registrationStore.pushAccountData()
setCheckBoxesSelected(true)
}

View File

@@ -8,6 +8,7 @@ import ProfileTable from '../../partials/digitalId/ProfileTable';
import Image from '../../images/transactions-image-04.svg';
const Profile = observer (() => {
console.log(registrationStore.accountData)
const [sidebarOpen, setSidebarOpen] = useState(false);
const [buttonPanelOpen, setButtonPanelOpen] = useState(true);
const [removePanelOpen, setRemovePanelOpen] = useState(false);
@@ -75,8 +76,10 @@ const Profile = observer (() => {
}
const deletePropertyData = () => {
const changeData = registrationStore.userData.data.filter(item=>!selectedItems.includes(item.label))
registrationStore.pushAccountData(changeData)
const newDataPush = {}
const changeData = userDataStore.decryptedData.filter(item=>!selectedItems.includes(item.key))
changeData.forEach(pushData=>newDataPush[pushData.key]=pushData.value)
registrationStore.pushAccountData(newDataPush)
}
const cancelAddPanel = () => {

View File

@@ -4,7 +4,7 @@ import {getNodeInfo} from '../api/node';
import {fetchWrapper} from '../shared/fetchWrapper';
class Store {
_accountData = {}
_accountData = []
_passPhrase='rocket north inform swift improve fringe sweet crew client canyon bean autumn'
@@ -17,17 +17,7 @@ class Store {
this.fetchNodeInfo()
reaction(() => this.tokenKey, () => fetchWrapper.getAuth('http://3.125.47.101/api/data/private', {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID
}).then((res) => this.userDataFetchChange(res)))
};
pushNewAccount() {
fetchWrapper.postAuth('http://3.125.47.101/api/data/private', {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID
}, [...this.encryptAccountData]).catch(()=>{})
reaction(() => this.tokenKey, () => this.fetchNewAccountData())
};
fetchNewAccountData() {
@@ -37,11 +27,11 @@ class Store {
}).then((res) => this.userDataFetchChange(res))
}
pushAccountData(data) {
pushAccountData(data=this.accountData) {
fetchWrapper.postAuth('http://3.125.47.101/api/data/private', {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID
}, [...data])
}, [...this.encryptAccountData(data)])
.then(()=>this.fetchNewAccountData())
}
@@ -83,8 +73,8 @@ class Store {
return this._accountData
};
get encryptAccountData() {
return Object.keys(this.accountData).map((label) => {
encryptAccountData(data) {
return Object.keys(data).map((label) => {
let value = cryptography.encryptMessageWithPassphrase(cryptography.getRandomBytes(32).toString('hex') + ":" + this.accountData[label], this.passPhrase, this.pubKey);
return {
"label": label,