Index: lib/adblockplus.js |
=================================================================== |
--- a/lib/adblockplus.js |
+++ b/lib/adblockplus.js |
@@ -365,23 +365,29 @@ |
ext.storage.get([key], function(items) |
{ |
var entry = items[key]; |
- if (!entry) |
+ if (entry) |
+ { |
+ resolve(entry); |
+ } |
+ else |
{ |
try |
{ |
- entry = JSON.parse(window.localStorage.getItem(key)); |
+ entry = localforage.getItem(key, function(err, value) |
kzar
2016/10/05 12:14:17
Since apparently `localforage.getItem` returns a p
Oleksandr
2016/10/05 13:32:40
I am not 100% sure I follow your suggestion, but w
kzar
2016/10/05 13:46:53
I mean for you do to something like this (untested
Oleksandr
2016/10/05 21:07:40
That won't work because like I said above we also
Sebastian Noack
2016/10/05 21:27:31
Why do we have to call ext.storage.get() first? I
Oleksandr
2016/10/05 21:49:12
Current ABP for Edge users have their subscription
Sebastian Noack
2016/10/05 21:53:30
Do they? Don't we use localStorage here in the ver
Oleksandr
2016/10/05 22:57:35
Ah, you're right. Version 0.9.6, which is the curr
|
+ { |
+ if (err || !value) |
+ { |
kzar
2016/10/05 12:14:17
Nit: No need for braces around if... else... claus
|
+ reject(new Error("File doesn't exist")); |
+ } |
+ else |
+ { |
+ resolve(value); |
+ } |
+ }); |
} |
catch (err) |
{} |
} |
- if (entry) |
- { |
- resolve(entry); |
- } |
- else |
- { |
- reject(new Error("File doesn't exist")); |
- } |
}); |
}.bind(this)); |
} |
@@ -389,28 +395,22 @@ |
{ |
var entry = {}; |
var key = fileToKey(file); |
+ entry[key] = { |
kzar
2016/10/05 12:14:17
Since this review is for changes to adblockplusedg
|
+ lastModified: Date.now(), |
+ content: data |
+ }; |
if (typeof browser == "undefined") |
{ |
- entry[key] = { |
- lastModified: Date.now(), |
- content: data |
- }; |
ext.storage.set(entry, callback); |
+ callback(); |
kzar
2016/10/05 12:14:17
Could you explain this change? How come ext.storag
Oleksandr
2016/10/05 13:32:40
Yeah, that was a bug.
|
} |
else |
{ |
- var processedData = LZString.compressToUTF16(JSON.stringify(data)); |
+ // Use IndexedDB to store data |
kzar
2016/10/05 12:14:17
This comment seems kind of pointless.
|
ext.storage.remove(key); |
- entry[key] = { |
- lastModified: Date.now(), |
- content: processedData, |
- compressed: true |
- }; |
- window.localStorage.setItem(key, JSON.stringify(entry[key])); |
- setTimeout(callback, 0); |
- } |
- callback(); |
+ localforage.setItem(key, entry[key], callback); |
+ } |
} |
exports.IO = { |
resolveFilePath: function(path) |
@@ -423,10 +423,6 @@ |
{ |
if ("content" in entry) |
{ |
- if (entry["compressed"]) |
- { |
- entry.content = JSON.parse(LZString.decompressFromUTF16(entry.content)); |
- } |
for (var _loopIndex15 = 0; _loopIndex15 < entry.content.length; ++_loopIndex15) |
{ |
var line = entry.content[_loopIndex15]; |