diff --git a/src/App.tsx b/src/App.tsx index b317b58..cb008bd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,16 +3,19 @@ import { hot } from 'react-hot-loader/root'; import { Layout } from 'antd'; import { GithubProvider } from './contexts/Github'; import { EncryptionProvider } from './contexts/Encryption'; +import { DecryptionProvider } from './contexts/Decryption'; import AppRouter from './Router'; const App: React.FC = () => ( - - - - - + + + + + + + ); diff --git a/src/Router.tsx b/src/Router.tsx index ee7f0e8..5b737d8 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -6,6 +6,7 @@ import { } from 'react-router-dom'; import Encrypt from './screens/Encrypt'; +import Decrypt from './screens/Decrypt'; import Welcome from './screens/Welcome'; import Debug from './screens/Debug'; @@ -18,6 +19,9 @@ const AppRouter: React.FC = () => ( + + + diff --git a/src/components/File.tsx b/src/components/File.tsx index 3461c38..1a20192 100644 --- a/src/components/File.tsx +++ b/src/components/File.tsx @@ -1,8 +1,7 @@ -import React, {useMemo} from 'react'; +import React from 'react'; import { List, Button, - Tooltip, Popconfirm, } from 'antd'; import { @@ -11,9 +10,8 @@ import { IssuesCloseOutlined, LockOutlined, DownloadOutlined, - ShareAltOutlined, } from '@ant-design/icons'; -import { FileType } from '../contexts/Encryption'; +import FileType from '../types/File'; import { downloadLink } from '../helpers/files'; interface Props { @@ -22,22 +20,11 @@ interface Props { } const icons: {[name: string]: any} = { - encrypting: , + processing: , failed: , - encrypted: , + success: , }; -const share = async (file: FileType, fileData: File[]) => { - try { - navigator.share({ - title: file.name, - files: fileData, - } as any); - } catch (err) { - alert(err); - } -} - const IconText = ({ icon, text, ...props }) => ( + + {Object.keys(files).length > 0 && ( + <> + Files + + + )} + + ); +}; + +export default Decrypt; diff --git a/src/screens/Encrypt.tsx b/src/screens/Encrypt.tsx index b685af3..5d12dac 100644 --- a/src/screens/Encrypt.tsx +++ b/src/screens/Encrypt.tsx @@ -1,13 +1,13 @@ import React, { useContext, useEffect } from 'react'; import { Divider } from 'antd'; import { useHistory } from 'react-router'; -import Add from '../components/Add'; +import Add from '../components/encrypt/Add'; import FileList from '../components/FileList'; import EncryptionContext from '../contexts/Encryption'; const Encrypt: React.FC = () => { const history = useHistory(); - const { files } = useContext(EncryptionContext); + const { files, deleteFile } = useContext(EncryptionContext); useEffect(() => { if (localStorage.getItem('welcome') !== 'seen') { history.replace('/welcome'); @@ -20,7 +20,14 @@ const Encrypt: React.FC = () => { {Object.keys(files).length > 0 && ( <> Files - + + + + Note: files are not send to me, you still have to download the encrypted files and send it to me. + )} diff --git a/src/types/File.ts b/src/types/File.ts new file mode 100644 index 0000000..e6ab39b --- /dev/null +++ b/src/types/File.ts @@ -0,0 +1,24 @@ +interface FileBase { + name: string; + status: string; + blob?: Blob; +} + +interface FileProcessing extends FileBase { + name: string; + status: 'processing'; +} + +interface FileFailed extends FileBase { + status: 'failed', + error: any; +} + +interface FileSuccess extends FileBase { + status: 'success'; + blob: Blob; +} + +type FileType = FileProcessing | FileFailed | FileSuccess; + +export default FileType;