|
4 | 4 | * |
5 | 5 | */ |
6 | 6 | import { saveAs } from 'file-saver'; |
| 7 | +import { b64toBlob } from '../../helpers/blob'; |
7 | 8 |
|
8 | 9 | export function getAllConfigDiff(toggleNotification, formatMessage, get) { |
9 | 10 | return async function(dispatch) { |
@@ -52,22 +53,13 @@ export function exportAllConfig(partialDiff, toggleNotification, formatMessage, |
52 | 53 | } |
53 | 54 |
|
54 | 55 | export function downloadZip(toggleNotification, formatMessage, post, get) { |
55 | | - return async function (dispatch) { |
| 56 | + return async function(dispatch) { |
56 | 57 | dispatch(setLoadingState(true)); |
57 | 58 | try { |
58 | 59 | const { message, base64Data, name } = await get('/config-sync/zip'); |
59 | 60 | toggleNotification({ type: 'success', message }); |
60 | 61 | if (base64Data) { |
61 | | - function b64toBlob(dataURI) { |
62 | | - const byteString = atob(dataURI); |
63 | | - const ab = new ArrayBuffer(byteString.length); |
64 | | - const ia = new Uint8Array(ab); |
65 | | - for (let i = 0; i < byteString.length; i++) { |
66 | | - ia[i] = byteString.charCodeAt(i); |
67 | | - } |
68 | | - return new Blob([ab], { type: 'image/jpeg' }); |
69 | | - } |
70 | | - saveAs(b64toBlob(base64Data), name, { type: 'application/zip' }) |
| 62 | + saveAs(b64toBlob(base64Data, 'application/zip'), name, { type: 'application/zip' }); |
71 | 63 | } |
72 | 64 | dispatch(setLoadingState(false)); |
73 | 65 | } catch (err) { |
|
0 commit comments