diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb990ace1..32f7890c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,9 @@
## v1.14.0
+**v1.14.0.13** *(2018-05-01)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.0.13/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.0.13/builds/4chan-X-noupdate.crx)]
+- Fix some bugs in data storage.
+
**v1.14.0.12** *(2018-04-01)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.0.12/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.0.12/builds/4chan-X-noupdate.crx)]
- Merge v1.13.15.10: Show 2018 Apr 01 team names in thread updates and other posts generated from JSON.
diff --git a/builds/4chan-X-beta.crx b/builds/4chan-X-beta.crx
index aec831d53..4e885f898 100644
Binary files a/builds/4chan-X-beta.crx and b/builds/4chan-X-beta.crx differ
diff --git a/builds/4chan-X-beta.meta.js b/builds/4chan-X-beta.meta.js
index a4caeb161..89dbf88cf 100644
--- a/builds/4chan-X-beta.meta.js
+++ b/builds/4chan-X-beta.meta.js
@@ -1,6 +1,6 @@
// ==UserScript==
// @name 4chan X beta
-// @version 1.14.0.12
+// @version 1.14.0.13
// @minGMVer 1.14
// @minFFVer 26
// @namespace 4chan-X
diff --git a/builds/4chan-X-beta.user.js b/builds/4chan-X-beta.user.js
index 0d3ac8189..5d96d901d 100644
--- a/builds/4chan-X-beta.user.js
+++ b/builds/4chan-X-beta.user.js
@@ -1,6 +1,6 @@
// ==UserScript==
// @name 4chan X beta
-// @version 1.14.0.12
+// @version 1.14.0.13
// @minGMVer 1.14
// @minFFVer 26
// @namespace 4chan-X
@@ -157,7 +157,7 @@ docSet = function() {
};
g = {
- VERSION: '1.14.0.12',
+ VERSION: '1.14.0.13',
NAMESPACE: '4chan X.',
boards: {}
};
@@ -5654,25 +5654,29 @@ DataBoard = (function() {
DataBoard.prototype.changes = [];
DataBoard.prototype.save = function(change, cb) {
- var changes, snapshot1;
- snapshot1 = JSON.stringify(this.allData);
change();
- changes = this.changes;
- changes.push(change);
+ this.changes.push(change);
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
- var c, i, len, snapshot2;
- _this.initData(items[_this.key]);
- snapshot2 = JSON.stringify(_this.allData);
- for (i = 0, len = changes.length; i < len; i++) {
- c = changes[i];
- c();
+ var i, len, needSync, ref;
+ if (!_this.changes.length) {
+ return;
}
+ needSync = (items[_this.key].version || 0) > (_this.allData.version || 0);
+ if (needSync) {
+ _this.initData(items[_this.key]);
+ ref = _this.changes;
+ for (i = 0, len = ref.length; i < len; i++) {
+ change = ref[i];
+ change();
+ }
+ }
+ _this.changes = [];
+ _this.allData.version = (_this.allData.version || 0) + 1;
return $.set(_this.key, _this.allData, function() {
- _this.changes = [];
- if (snapshot1 !== snapshot2) {
+ if (needSync) {
if (typeof _this.sync === "function") {
_this.sync();
}
@@ -5684,21 +5688,18 @@ DataBoard = (function() {
};
DataBoard.prototype.forceSync = function(cb) {
- var changes, snapshot1;
- snapshot1 = JSON.stringify(this.allData);
- changes = this.changes;
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
- var c, i, len, snapshot2;
- _this.initData(items[_this.key]);
- snapshot2 = JSON.stringify(_this.allData);
- for (i = 0, len = changes.length; i < len; i++) {
- c = changes[i];
- c();
- }
- if (snapshot1 !== snapshot2) {
+ var change, i, len, ref;
+ if ((items[_this.key].version || 0) > (_this.allData.version || 0)) {
+ _this.initData(items[_this.key]);
+ ref = _this.changes;
+ for (i = 0, len = ref.length; i < len; i++) {
+ change = ref[i];
+ change();
+ }
if (typeof _this.sync === "function") {
_this.sync();
}
@@ -5906,6 +5907,9 @@ DataBoard = (function() {
};
DataBoard.prototype.onSync = function(data) {
+ if (!((data.version || 0) > (this.allData.version || 0))) {
+ return;
+ }
this.initData(data);
return typeof this.sync === "function" ? this.sync() : void 0;
};
diff --git a/builds/4chan-X-noupdate.crx b/builds/4chan-X-noupdate.crx
index 3aa2198ca..d8f48da31 100644
Binary files a/builds/4chan-X-noupdate.crx and b/builds/4chan-X-noupdate.crx differ
diff --git a/builds/4chan-X-noupdate.user.js b/builds/4chan-X-noupdate.user.js
index e8c68a5d8..d66eadf4c 100644
--- a/builds/4chan-X-noupdate.user.js
+++ b/builds/4chan-X-noupdate.user.js
@@ -1,6 +1,6 @@
// ==UserScript==
// @name 4chan X
-// @version 1.14.0.12
+// @version 1.14.0.13
// @minGMVer 1.14
// @minFFVer 26
// @namespace 4chan-X
@@ -157,7 +157,7 @@ docSet = function() {
};
g = {
- VERSION: '1.14.0.12',
+ VERSION: '1.14.0.13',
NAMESPACE: '4chan X.',
boards: {}
};
@@ -5654,25 +5654,29 @@ DataBoard = (function() {
DataBoard.prototype.changes = [];
DataBoard.prototype.save = function(change, cb) {
- var changes, snapshot1;
- snapshot1 = JSON.stringify(this.allData);
change();
- changes = this.changes;
- changes.push(change);
+ this.changes.push(change);
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
- var c, i, len, snapshot2;
- _this.initData(items[_this.key]);
- snapshot2 = JSON.stringify(_this.allData);
- for (i = 0, len = changes.length; i < len; i++) {
- c = changes[i];
- c();
+ var i, len, needSync, ref;
+ if (!_this.changes.length) {
+ return;
}
+ needSync = (items[_this.key].version || 0) > (_this.allData.version || 0);
+ if (needSync) {
+ _this.initData(items[_this.key]);
+ ref = _this.changes;
+ for (i = 0, len = ref.length; i < len; i++) {
+ change = ref[i];
+ change();
+ }
+ }
+ _this.changes = [];
+ _this.allData.version = (_this.allData.version || 0) + 1;
return $.set(_this.key, _this.allData, function() {
- _this.changes = [];
- if (snapshot1 !== snapshot2) {
+ if (needSync) {
if (typeof _this.sync === "function") {
_this.sync();
}
@@ -5684,21 +5688,18 @@ DataBoard = (function() {
};
DataBoard.prototype.forceSync = function(cb) {
- var changes, snapshot1;
- snapshot1 = JSON.stringify(this.allData);
- changes = this.changes;
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
- var c, i, len, snapshot2;
- _this.initData(items[_this.key]);
- snapshot2 = JSON.stringify(_this.allData);
- for (i = 0, len = changes.length; i < len; i++) {
- c = changes[i];
- c();
- }
- if (snapshot1 !== snapshot2) {
+ var change, i, len, ref;
+ if ((items[_this.key].version || 0) > (_this.allData.version || 0)) {
+ _this.initData(items[_this.key]);
+ ref = _this.changes;
+ for (i = 0, len = ref.length; i < len; i++) {
+ change = ref[i];
+ change();
+ }
if (typeof _this.sync === "function") {
_this.sync();
}
@@ -5906,6 +5907,9 @@ DataBoard = (function() {
};
DataBoard.prototype.onSync = function(data) {
+ if (!((data.version || 0) > (this.allData.version || 0))) {
+ return;
+ }
this.initData(data);
return typeof this.sync === "function" ? this.sync() : void 0;
};
diff --git a/builds/4chan-X.crx b/builds/4chan-X.crx
index c3aa1ad45..1dbf2881b 100644
Binary files a/builds/4chan-X.crx and b/builds/4chan-X.crx differ
diff --git a/builds/4chan-X.meta.js b/builds/4chan-X.meta.js
index 9686daa03..fb8831905 100644
--- a/builds/4chan-X.meta.js
+++ b/builds/4chan-X.meta.js
@@ -1,6 +1,6 @@
// ==UserScript==
// @name 4chan X
-// @version 1.14.0.12
+// @version 1.14.0.13
// @minGMVer 1.14
// @minFFVer 26
// @namespace 4chan-X
diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js
index 0da12e5c9..d8be82485 100644
--- a/builds/4chan-X.user.js
+++ b/builds/4chan-X.user.js
@@ -1,6 +1,6 @@
// ==UserScript==
// @name 4chan X
-// @version 1.14.0.12
+// @version 1.14.0.13
// @minGMVer 1.14
// @minFFVer 26
// @namespace 4chan-X
@@ -157,7 +157,7 @@ docSet = function() {
};
g = {
- VERSION: '1.14.0.12',
+ VERSION: '1.14.0.13',
NAMESPACE: '4chan X.',
boards: {}
};
@@ -5654,25 +5654,29 @@ DataBoard = (function() {
DataBoard.prototype.changes = [];
DataBoard.prototype.save = function(change, cb) {
- var changes, snapshot1;
- snapshot1 = JSON.stringify(this.allData);
change();
- changes = this.changes;
- changes.push(change);
+ this.changes.push(change);
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
- var c, i, len, snapshot2;
- _this.initData(items[_this.key]);
- snapshot2 = JSON.stringify(_this.allData);
- for (i = 0, len = changes.length; i < len; i++) {
- c = changes[i];
- c();
+ var i, len, needSync, ref;
+ if (!_this.changes.length) {
+ return;
}
+ needSync = (items[_this.key].version || 0) > (_this.allData.version || 0);
+ if (needSync) {
+ _this.initData(items[_this.key]);
+ ref = _this.changes;
+ for (i = 0, len = ref.length; i < len; i++) {
+ change = ref[i];
+ change();
+ }
+ }
+ _this.changes = [];
+ _this.allData.version = (_this.allData.version || 0) + 1;
return $.set(_this.key, _this.allData, function() {
- _this.changes = [];
- if (snapshot1 !== snapshot2) {
+ if (needSync) {
if (typeof _this.sync === "function") {
_this.sync();
}
@@ -5684,21 +5688,18 @@ DataBoard = (function() {
};
DataBoard.prototype.forceSync = function(cb) {
- var changes, snapshot1;
- snapshot1 = JSON.stringify(this.allData);
- changes = this.changes;
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
- var c, i, len, snapshot2;
- _this.initData(items[_this.key]);
- snapshot2 = JSON.stringify(_this.allData);
- for (i = 0, len = changes.length; i < len; i++) {
- c = changes[i];
- c();
- }
- if (snapshot1 !== snapshot2) {
+ var change, i, len, ref;
+ if ((items[_this.key].version || 0) > (_this.allData.version || 0)) {
+ _this.initData(items[_this.key]);
+ ref = _this.changes;
+ for (i = 0, len = ref.length; i < len; i++) {
+ change = ref[i];
+ change();
+ }
if (typeof _this.sync === "function") {
_this.sync();
}
@@ -5906,6 +5907,9 @@ DataBoard = (function() {
};
DataBoard.prototype.onSync = function(data) {
+ if (!((data.version || 0) > (this.allData.version || 0))) {
+ return;
+ }
this.initData(data);
return typeof this.sync === "function" ? this.sync() : void 0;
};
diff --git a/builds/4chan-X.zip b/builds/4chan-X.zip
index f3349ea02..05f37dba1 100644
Binary files a/builds/4chan-X.zip and b/builds/4chan-X.zip differ
diff --git a/builds/updates-beta.json b/builds/updates-beta.json
index 6c6cb441a..a1b494693 100644
--- a/builds/updates-beta.json
+++ b/builds/updates-beta.json
@@ -3,7 +3,7 @@
"4chan-x@4chan-x.net": {
"updates": [
{
- "version": "1.14.0.12",
+ "version": "1.14.0.13",
"update_link": "https://www.4chan-x.net/builds/4chan-X-beta.crx"
}
]
diff --git a/builds/updates-beta.xml b/builds/updates-beta.xml
index 6a7f69151..3cc40c309 100644
--- a/builds/updates-beta.xml
+++ b/builds/updates-beta.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/builds/updates.json b/builds/updates.json
index 7535e5307..3381910cb 100644
--- a/builds/updates.json
+++ b/builds/updates.json
@@ -3,7 +3,7 @@
"4chan-x@4chan-x.net": {
"updates": [
{
- "version": "1.14.0.12",
+ "version": "1.14.0.13",
"update_link": "https://www.4chan-x.net/builds/4chan-X.crx"
}
]
diff --git a/builds/updates.xml b/builds/updates.xml
index 4939899c1..8e36433a5 100644
--- a/builds/updates.xml
+++ b/builds/updates.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/version.json b/version.json
index 19836b2cd..23d80a669 100644
--- a/version.json
+++ b/version.json
@@ -1,4 +1,4 @@
{
- "version": "1.14.0.12",
- "date": "2018-04-01T04:59:25.833Z"
+ "version": "1.14.0.13",
+ "date": "2018-05-01T22:20:21.861Z"
}
\ No newline at end of file