Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/adblockplus.js

Issue 29348698: NoIssue - Use localStorage for storing filters in current Windows Store version of ABP for Edge (Closed)
Patch Set: Created July 27, 2016, 7:29 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/adblockplus.js
===================================================================
--- a/lib/adblockplus.js
+++ b/lib/adblockplus.js
@@ -360,27 +360,28 @@
function loadFile(file, successCallback, errorCallback)
{
var key = fileToKey(file);
- ext.storage.get([key], function(items)
- {
- var entry = items[key];
- if (entry)
- {
- successCallback(entry);
- }
- else
- {
- errorCallback(new Error("File doesn't exist"));
- }
- });
+ dataInJson = localStorage.getItem(key);
+ if (dataInJson != null)
kzar 2016/07/27 08:44:21 Perhaps just check if dataInJson is truthy like th
+ successCallback(JSON.parse(dataInJson));
+ else
+ errorCallback(new Error("File doesn't exist"));
}
function saveFile(file, data, callback)
{
- ext.storage.set(fileToKey(file),
- {
- content: data,
- lastModified: Date.now()
- }, callback);
+ try
+ {
+ localStorage.setItem(fileToKey(file), JSON.stringify({
kzar 2016/07/27 08:44:21 Nit: The indentation here looks kind of weird. How
+ content: data,
+ lastModified: Date.now()
+ }
+ ));
+ }
+ catch(error)
+ {
+ // QuotaExceededError can happen. Ignore silently
kzar 2016/07/27 08:44:21 Maybe we should display an alert that asks the use
+ }
+ callback();
}
exports.IO = {
resolveFilePath: function(path)
« no previous file with comments | « no previous file | manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld