Skip to content

Commit

Permalink
chore: bump to 0.2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe committed Jul 4, 2014
1 parent 2e166e0 commit 62667ad
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 48 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
<a name="0.2.8"></a>
# 0.2.8 (2014-07-04)


## Bug Fixes

- Safari private browsing would not resolve
([224fca6d](https://github.com/ocombe/angular-localForage/commit/224fca6d99967bce37b0cc05f8737f545ca33d1b))
- better fix for the Firefox private browsing invalidStateError
([c566a19b](https://github.com/ocombe/angular-localForage/commit/c566a19ba4223834869902df9ea3ea0f980f3965))


## Features

- bump to localForage 0.9.1 and use of the new `keys` function
([4f9431a6](https://github.com/ocombe/angular-localForage/commit/4f9431a6af62f1328ea5aa05cb0f7acafe8a4254))


<a name="0.2.7"></a>
# 0.2.7 (2014-07-03)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-localForage",
"main": "dist/angular-localForage.js",
"version": "0.2.7",
"version": "0.2.8",
"homepage": "https://github.com/ocombe/angular-localForage",
"authors": ["Olivier Combe <[email protected]>"],
"description": "Angular service & directive for https://github.com/mozilla/localForage (Offline storage, improved.)",
Expand Down
66 changes: 22 additions & 44 deletions dist/angular-localForage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* angular-localForage - Angular service & directive for https://github.com/mozilla/localForage (Offline storage, improved.)
* @version v0.2.7
* @version v0.2.8
* @link https://github.com/ocombe/angular-localForage
* @license MIT
* @author Olivier Combe <[email protected]>
Expand Down Expand Up @@ -44,26 +44,6 @@
if(!angular.isObject(config)) {
config = {};
}
var is_firefox = /firefox/i.test(navigator.userAgent);
if(is_firefox) {
try {
var indexedDB = indexedDB || this.indexedDB || this.webkitIndexedDB ||
this.mozIndexedDB || this.OIndexedDB ||
this.msIndexedDB;

var test = indexedDB.open('_localforage_spec_test', 1);
test.onerror = function() {
supportsIndexedDB = false;
}

var supportsIndexedDB = indexedDB && test.onupgradeneeded === null;
} catch(e) {
supportsIndexedDB = false;
}
if(!supportsIndexedDB) {
config.driver = 'localStorageWrapper';
}
}
if(angular.isDefined(config.driver)) {
localforage.config(config);
return setDriver(config.driver);
Expand All @@ -80,19 +60,21 @@
return driver() === 'localStorageWrapper' ? localforage.config().name + '.' : '';
}

var onError = function(data, args, fct, deferred) {
if(data === 'InvalidStateError' && driver() === 'asyncStorage') {
var onError = function(err, args, fct, deferred) {
// test for private browsing errors in Firefox & Safari
if(((angular.isObject(err) && err.name ? err.name === 'InvalidStateError' : (angular.isString(err) && err === 'InvalidStateError')) && driver() === 'asyncStorage')
|| (angular.isObject(err) && err.code && err.code === 5)) {
setDriver('localStorageWrapper').then(function() {
fct(args).then(function(item) {
fct.apply(this, args).then(function(item) {
deferred.resolve(item);
}, function(data) {
deferred.reject(data);
});
}, function() {
deferred.reject(data);
deferred.reject(err);
});
} else {
deferred.reject(data);
deferred.reject(err);
}
}

Expand Down Expand Up @@ -147,7 +129,7 @@
var deferred = $q.defer(),
args = arguments,
promises = [];
getKeys().then(function success(keys) {
keys().then(function success(keys) {
angular.forEach(keys, function(key) {
promises.push(removeItem(key));
});
Expand Down Expand Up @@ -185,26 +167,21 @@
}

// Return the list of keys stored for this application
var getKeys = function() {
var keys = function() {
var deferred = $q.defer(),
args = arguments;
length().then(function success(length) {
var promises = [],
keys = [],
p = prefix();
for(var i = 0; i < length; i++) {
promises.push(key(i).then(function(key) {
if(!!key && key.indexOf(p) === 0) {
keys.push(key.substr(p.length, key.length));
}
}));
localforage.keys().then(function success(keyList) {
// because we may have a prefix, extract only related keys
var p = prefix(),
fixedKeyList = [];
for(var i = 0, len = keyList.length; i < len; i++) {
if(!!keyList[i] && keyList[i].indexOf(p) === 0) {
fixedKeyList.push(keyList[i].substr(p.length, keyList[i].length));
}
}

$q.all(promises).then(function() {
deferred.resolve(keys);
});
deferred.resolve(fixedKeyList);
}, function error(data) {
onError(data, args, getKeys, deferred);
onError(data, args, keys, deferred);
});
return deferred.promise;
}
Expand Down Expand Up @@ -292,7 +269,8 @@
clearAll: clear, // deprecated
key: key,
getKeyAt: key, // deprecated
getKeys: getKeys,
keys: keys,
getKeys: keys, // deprecated
length: length,
getLength: length, // deprecated
bind: bind,
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-localForage.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-localForage",
"version": "0.2.7",
"version": "0.2.8",
"description": "Angular service & directive for https://github.com/mozilla/localForage (Offline storage, improved.)",
"license": "MIT",
"main": "dist/angular-localForage.js",
Expand Down

0 comments on commit 62667ad

Please sign in to comment.