Fix broken import-from-file in Whitelist pane

Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/bt2d1f/
This commit is contained in:
Raymond Hill 2019-05-26 08:03:44 -04:00
parent 44fd5b1473
commit 85b89fbe63
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -157,19 +157,19 @@ const renderWhitelist = function() {
/******************************************************************************/
const handleImportFilePicker = function() {
const fileReaderOnLoadHandler = ( ) => {
cmEditor.setValue(
[
cmEditor.getValue().trim(),
this.result.trim()
].join('\n').trim()
);
};
const file = this.files[0];
if ( file === undefined || file.name === '' ) { return; }
if ( file.type.indexOf('text') !== 0 ) { return; }
const fr = new FileReader();
fr.onload = fileReaderOnLoadHandler;
fr.onload = ev => {
if ( ev.type !== 'load' ) { return; }
cmEditor.setValue(
[
cmEditor.getValue().trim(),
fr.result.trim()
].join('\n').trim()
);
};
fr.readAsText(file);
};