Fix eslint error in dropbox implementation

This commit is contained in:
Matheus Faustino 2018-08-08 19:35:18 -03:00
parent b2ca87079c
commit 6644f803d8

View File

@ -1,9 +1,4 @@
/* global messageBox */ /* global messageBox Dropbox createZipFileFromText readZipFileFromBlob launchWebAuthFlow getRedirectUrlAuthFlow importFromString resolve */
/* global Dropbox */
/* global createZipFileFromText */
/* global readZipFileFromBlob */
/* global launchWebAuthFlow */
/* global getRedirectUrlAuthFlow */
'use strict'; 'use strict';
const DROPBOX_API_KEY = ''; const DROPBOX_API_KEY = '';
@ -150,15 +145,12 @@ $('#sync-dropbox-import').onclick = () => {
.then(zipedFileBlob => { .then(zipedFileBlob => {
messageProgressBar({title: title, text: t('readingStyles')}); messageProgressBar({title: title, text: t('readingStyles')});
const fileBlob = zipedFileBlob; document.body.style.cursor = 'wait';
// it's based on the import-export.js
const fReader = new FileReader(); const fReader = new FileReader();
fReader.onloadend = event => { fReader.onloadend = event => {
const text = event.target.result; const text = event.target.result;
const maybeUsercss = !/^[\s\r\n]*\[/.test(text) && const maybeUsercss = !/^[\s\r\n]*\[/.test(text) &&
(text.includes('==UserStyle==') || /==UserStyle==/i.test(text)); (text.includes('==UserStyle==') || /==UserStyle==/i.test(text));
(!maybeUsercss ? (!maybeUsercss ?
importFromString(text) : importFromString(text) :
getOwnTab().then(tab => { getOwnTab().then(tab => {
@ -166,9 +158,12 @@ $('#sync-dropbox-import').onclick = () => {
return API.installUsercss({direct: true, tab}) return API.installUsercss({direct: true, tab})
.then(() => URL.revokeObjectURL(tab.url)); .then(() => URL.revokeObjectURL(tab.url));
}) })
); ).then(numStyles => {
document.body.style.cursor = '';
resolve(numStyles);
});
}; };
fReader.readAsText(fileBlob, 'utf-8'); fReader.readAsText(zipedFileBlob, 'utf-8');
}) })
.catch(error => { .catch(error => {
// no file // no file