Creating encrypted file in desktop

This commit is contained in:
Vladislav Makhov 2020-12-02 16:45:09 +03:00
parent 925a619a2f
commit e911caf665

View File

@ -55,7 +55,7 @@ import { setEncryptionAccess } from "../../../../../helpers/desktop";
const { FileAction } = constants; const { FileAction } = constants;
const sideColor = "#A3A9AE"; const sideColor = "#A3A9AE";
const { getSettings } = initStore.auth.selectors; const { getSettings } = initStore.auth.selectors;
const { getEncryptionAccess } = initStore.auth.actions; const { getEncryptionAccess, replaceFileStream } = initStore.auth.actions;
const SimpleFilesRowContent = styled(RowContent)` const SimpleFilesRowContent = styled(RowContent)`
.badge-ext { .badge-ext {
@ -166,6 +166,7 @@ class FilesRowContent extends React.PureComponent {
openDocEditor, openDocEditor,
isPrivacy, isPrivacy,
getEncryptionAccess, getEncryptionAccess,
replaceFileStream,
} = this.props; } = this.props;
const { itemTitle } = this.state; const { itemTitle } = this.state;
@ -176,16 +177,29 @@ class FilesRowContent extends React.PureComponent {
if (itemTitle.trim() === "") return this.completeAction(itemId); if (itemTitle.trim() === "") return this.completeAction(itemId);
let tab = item.fileExst ? window.open("about:blank", "_blank") : null; let tab = item.fileExst ? window.open("about:blank", "_blank") : null;
//debugger;
!item.fileExst !item.fileExst
? createFolder(item.parentId, itemTitle) ? createFolder(item.parentId, itemTitle)
.then(() => this.completeAction(itemId)) .then(() => this.completeAction(itemId))
.finally(() => setIsLoading(false)) .finally(() => setIsLoading(false))
: createFile(item.parentId, `${itemTitle}.${item.fileExst}`) : createFile(item.parentId, `${itemTitle}.${item.fileExst}`)
.then((file) => { .then((file) => {
openDocEditor(file.id, tab, file.webUrl); if (isPrivacy) {
this.completeAction(itemId); setEncryptionAccess(file, (encryptedFile) => {
if (encryptedFile) {
replaceFileStream(
file.id,
itemTitle,
encryptedFile,
true,
false
);
}
});
}
//openDocEditor(file.id, tab, file.webUrl);
}) })
.then(() => this.completeAction(itemId))
.finally(() => setIsLoading(false)); .finally(() => setIsLoading(false));
}; };
@ -696,4 +710,5 @@ export default connect(mapStateToProps, {
clearProgressData, clearProgressData,
fetchFiles, fetchFiles,
getEncryptionAccess, getEncryptionAccess,
replaceFileStream,
})(withRouter(withTranslation()(FilesRowContent))); })(withRouter(withTranslation()(FilesRowContent)));