Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
saveNewFile() {
// this.setState({ loading: "show" });
// this.setState({ save: "hide"});
blockstack.putFile("documents.json", JSON.stringify(this.state), true)
.then(() => {
console.log(JSON.stringify(this.state));
window.location.href = '/';
})
.catch(e => {
console.log("e");
console.log(e);
alert(e.message);
});
}
handleCancel() {
console.log(userShort + this.props.match.params.id + '.json')
// console.log("Step Four: File Shared: " + getGlobal().shareFile);
setGlobal({ shareModal: "hide", loading: "hide", show: "" });
window.Materialize.toast('File shared with ' + getGlobal().receiverID, 4000);
})
.catch(e => {
console.log("e");
console.log(e);
});
const publicKey = getGlobal().pubKey;
const data = getGlobal().shareFileIndex;
const dataTwo = getGlobal().shareFile;
const encryptedData = JSON.stringify(encryptECIES(publicKey, JSON.stringify(data)));
const encryptedDataTwo = JSON.stringify(encryptECIES(publicKey, JSON.stringify(dataTwo)));
const directory = '/shared/' + file;
putFile(directory, encryptedData, {encrypt: false})
.then(() => {
console.log("Shared encrypted fileIndex" + directory);
})
.catch(e => {
console.log(e);
});
putFile('/shared/' + userShort + this.props.match.params.id + '.json', encryptedDataTwo, {encrypt: false})
.then(() => {
console.log("Shared encrypted file");
console.log(dataTwo);
handleaddItem();
})
.catch(e => {
console.log(e);
});
export function saveNewSingleSharedDoc() {
const file = this.state.tempDocId;
const fullFile = '/documents/' + file + '.json'
putFile(fullFile, JSON.stringify(this.state.singleDoc), {encrypt:true})
.then(() => {
console.log("Saved!");
if(this.state.rtc !== true) {
window.location.replace("/documents");
}
})
.catch(e => {
console.log("e");
console.log(e);
});
}
saveFile() {
console.log("Saving logged in user's file")
this.setState({count: 0, updatedAccountName: "" });
putFile('automergeTest.json', JSON.stringify(this.state.file), {encrypt: true})
.then(() => {
console.log("file saved");
this.setState({
integrationsModal: "hide",
accountNameModal: "hide",
accountPlanModal: "hide",
updateTeammateModal: "hide",
teammateModal: "hide"
});
//Since this method will be reused for all saves made by the logged in user, it's helpful to always save to the other team members, so we start by loading their public keys
this.saveToEveryone();
})
.catch(error => {
console.log(error);
})
}
saveNewFile() {
const fileName = this.state.conversationUser.slice(0, -3) + '.json';
putFile(fileName, JSON.stringify(this.state), {encrypt: true})
.then(() => {
this.setState({deleteShow: "hide"});
this.saveShared();
})
.catch(e => {
console.log(e);
});
}
autoSave() {
const file = this.props.match.params.id;
const fullFile = '/sheets/' + file + '.json';
if(this.state.singleSheet.form === true) {
putFile(fullFile, JSON.stringify(this.state.singleSheet), {encrypt: false})
.then(() => {
console.log("Autosaved");
this.saveCollection();
})
.catch(e => {
console.log("e");
console.log(e);
});
} else {
putFile(fullFile, JSON.stringify(this.state.singleSheet), {encrypt: true})
.then(() => {
console.log("Autosaved");
this.saveCollection();
})
.catch(e => {
console.log("e");
console.log(e);
});
}
}
.catch(error => {
console.log(error);
})
putFile('inviter.json', JSON.stringify({}), {encrypt: true})
.catch(error => {
console.log(error);
});
putFile('inviteStatus.json', JSON.stringify({}), {encrypt: true})
.catch(error => {
console.log(error);
})
putFile("accountdetailsMain.json", JSON.stringify({}), {encrypt: false})
.catch(error => {
console.log(error)
})
}
export function saveToDocs() {
putFile("documentscollection.json", JSON.stringify(getGlobal().value), { encrypt: true })
.then(() => {
console.log("Saved!");
saveToDocsTwo();
})
.catch(e => {
console.log("e");
console.log(e);
});
}
export function saveToDocsTwo() {
export function saveSingleFile(doc) {
const file = doc.id;
const fullFile = '/documents/' + file + '.json'
putFile(fullFile, JSON.stringify(getGlobal().singleDoc), {encrypt:true})
.then(() => {
console.log("Saved!");
saveCollection();
})
.catch(e => {
console.log("e");
console.log(e);
});
}
.then((_userData : UserData) => {
return blockstack.putFile(gaiaPath, data, { encrypt: encrypt, sign: sign });
})
.then((url : string) => {