From 4f92dcd3ed5f3f092015282e0d635d87569cb082 Mon Sep 17 00:00:00 2001 From: Morten Olsen Date: Thu, 20 Aug 2020 00:15:36 +0200 Subject: [PATCH] Improvments --- src/components/File.tsx | 72 +++++++++++++++++++++++++++---------- src/contexts/Encryption.tsx | 6 ++-- src/contexts/Github.tsx | 8 +++-- 3 files changed, 63 insertions(+), 23 deletions(-) diff --git a/src/components/File.tsx b/src/components/File.tsx index c160896..c3b4f2c 100644 --- a/src/components/File.tsx +++ b/src/components/File.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useMemo} from 'react'; import { List, Button, @@ -8,16 +8,18 @@ import { SyncOutlined, IssuesCloseOutlined, LockOutlined, + DownloadOutlined, + ShareAltOutlined, } from '@ant-design/icons'; import { FileType } from '../contexts/Encryption'; -import { CheckCircle, XCircle, Download, Trash, Loader } from 'react-feather'; interface Props { remove: () => void; file: FileType; } -const downloadLink = (name: string, url: string) => { +const downloadLink = (name: string, blob: Blob) => { + const url = URL.createObjectURL(blob); const downloadLink = document.createElement('a'); downloadLink.href = url; downloadLink.download = name; @@ -32,6 +34,17 @@ const icons: {[name: string]: any} = { encrypted: , }; +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 }) => (