Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 69240e2

Browse files
author
Wei Li
authored
Merge pull request #295 from feedhenry/update-sync-js
fix indexdb issue with sync
2 parents 94237a6 + e8371b4 commit 69240e2

File tree

5 files changed

+145
-127
lines changed

5 files changed

+145
-127
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog - FeedHenry Javascript SDK
2+
## 3.1.1 - 2019-11-08
3+
### Change
4+
- Upgrade version of fh-sync-js from 1.4.0 to 1.4.2
5+
- Update lawnchair changes from [email protected]
26

37
## 3.1.0 - 2019-04-15
48
### Change

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fh-js-sdk",
3-
"version": "3.0.4",
3+
"version": "3.1.1",
44
"homepage": "https://github.com/feedhenry/fh-js-sdk",
55
"authors": [
66

libs/lawnchair/lawnchairIndexDbAdapter.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Lawnchair.adapter('indexed-db', (function(){
1212

1313
return {
1414
valid: function () { return !!getIDB(); },
15-
15+
1616
close: function () {
1717
if (this.db) {
1818
this.db.close();
@@ -30,7 +30,16 @@ Lawnchair.adapter('indexed-db', (function(){
3030
//FEEDHENRY CHANGE TO ALLOW ERROR CALLBACK
3131
if(options && 'function' === typeof options.fail) fail = options.fail
3232
//END CHANGE
33+
34+
var to = setTimeout(function(){
35+
if (request.readyState != 'done') {
36+
console.error('opendb request is still not ready. current readyState: ' + request.readyState + '. Returning error.');
37+
return fail(new Error('OPEN_DB_ERROR'));
38+
}
39+
}, 2000);
40+
3341
request.onupgradeneeded = function (event) {
42+
clearTimeout(to);
3443
self.store = request.result.createObjectStore("teststore", { autoIncrement: true });
3544
for (var i = 0; i < self.waiting.length; i++) {
3645
self.waiting[i].call(self);
@@ -40,6 +49,7 @@ Lawnchair.adapter('indexed-db', (function(){
4049
};
4150

4251
request.onsuccess = function (event) {
52+
clearTimeout(to);
4353
self.db = request.result;
4454

4555
if (self.db.version != "2.0") {
@@ -71,7 +81,11 @@ Lawnchair.adapter('indexed-db', (function(){
7181
}
7282
};
7383

74-
request.onerror = fail;
84+
request.onerror = function(){
85+
clearTimeout(to);
86+
var error = request.error;
87+
fail(error);
88+
};
7589
},
7690

7791
save:function(obj, callback) {

0 commit comments

Comments
 (0)