qiscus-sdk-core 2.12.0 → 2.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -155,7 +155,8 @@ var QiscusSDK = /*#__PURE__*/function () {
155
155
  this.templateFunction = null;
156
156
  this.debugMode = false;
157
157
  this.debugMQTTMode = false;
158
- this._customHeader = {}; // to prevent double receive newmessages callback
158
+ this._customHeader = {};
159
+ this._forceEnableSync = true; // to prevent double receive newmessages callback
159
160
 
160
161
  this.lastReceiveMessages = [];
161
162
  this._hookAdapter = (0, _hook.hookAdapterFactory)();
@@ -432,7 +433,7 @@ var QiscusSDK = /*#__PURE__*/function () {
432
433
  return _this2.syncInterval;
433
434
  },
434
435
  getShouldSync: function getShouldSync() {
435
- return _this2.isLogin && !_this2.realtimeAdapter.connected;
436
+ return _this2._forceEnableSync && _this2.isLogin && !_this2.realtimeAdapter.connected;
436
437
  },
437
438
  syncOnConnect: function syncOnConnect() {
438
439
  return _this2.syncOnConnect;
@@ -2886,6 +2887,54 @@ var QiscusSDK = /*#__PURE__*/function () {
2886
2887
 
2887
2888
  return openRealtimeConnection;
2888
2889
  }()
2890
+ }, {
2891
+ key: "startSync",
2892
+ value: function () {
2893
+ var _startSync = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee21() {
2894
+ return _regenerator["default"].wrap(function _callee21$(_context21) {
2895
+ while (1) {
2896
+ switch (_context21.prev = _context21.next) {
2897
+ case 0:
2898
+ this._forceEnableSync = true;
2899
+
2900
+ case 1:
2901
+ case "end":
2902
+ return _context21.stop();
2903
+ }
2904
+ }
2905
+ }, _callee21, this);
2906
+ }));
2907
+
2908
+ function startSync() {
2909
+ return _startSync.apply(this, arguments);
2910
+ }
2911
+
2912
+ return startSync;
2913
+ }()
2914
+ }, {
2915
+ key: "stopSync",
2916
+ value: function () {
2917
+ var _stopSync = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee22() {
2918
+ return _regenerator["default"].wrap(function _callee22$(_context22) {
2919
+ while (1) {
2920
+ switch (_context22.prev = _context22.next) {
2921
+ case 0:
2922
+ this._forceEnableSync = false;
2923
+
2924
+ case 1:
2925
+ case "end":
2926
+ return _context22.stop();
2927
+ }
2928
+ }
2929
+ }, _callee22, this);
2930
+ }));
2931
+
2932
+ function stopSync() {
2933
+ return _stopSync.apply(this, arguments);
2934
+ }
2935
+
2936
+ return stopSync;
2937
+ }()
2889
2938
  }, {
2890
2939
  key: "uploadURL",
2891
2940
  get: function get() {
package/lib/lib/Room.js CHANGED
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = exports.Room = void 0;
9
9
 
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
10
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
13
 
12
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -105,7 +107,7 @@ var Room = /*#__PURE__*/function () {
105
107
  commentToFind.time = comment.time;
106
108
  commentToFind.unix_timestamp = comment.unix_timestamp;
107
109
  } else {
108
- this.comments.push(comment); // this.comments.sort((a, b) => a.date - b.date)
110
+ this.comments = [].concat((0, _toConsumableArray2["default"])(this.comments), [comment]);
109
111
  }
110
112
  }
111
113
  }, {
@@ -189,8 +189,6 @@ var HttpAdapter = /*#__PURE__*/function () {
189
189
  req.set("QISCUS-SDK-USER-ID", "".concat(this.userId));
190
190
  }
191
191
 
192
- console.log('this.token:', this.token);
193
-
194
192
  if (this.token != null) {
195
193
  req.set("QISCUS-SDK-TOKEN", "".concat(this.token));
196
194
  }
@@ -75,7 +75,7 @@ function synchronizeFactory(getHttp, getInterval, getSync, getId, logger) {
75
75
 
76
76
  accumulatedInterval += interval;
77
77
 
78
- if (!(accumulatedInterval >= getInterval() && shouldSync)) {
78
+ if (!(accumulatedInterval >= getInterval() && shouldSync())) {
79
79
  _context.next = 9;
80
80
  break;
81
81
  }
@@ -285,7 +285,7 @@ function synchronizeEventFactory(getHttp, getInterval, getSync, getId, logger) {
285
285
 
286
286
  accumulatedInterval += interval;
287
287
 
288
- if (!(accumulatedInterval >= getInterval() && shouldSync)) {
288
+ if (!(accumulatedInterval >= getInterval() && shouldSync())) {
289
289
  _context3.next = 9;
290
290
  break;
291
291
  }
@@ -463,7 +463,7 @@ function SyncAdapter(getHttpAdapter, _ref) {
463
463
  return syncOnConnect();
464
464
  }
465
465
 
466
- return;
466
+ return 0;
467
467
  };
468
468
 
469
469
  var syncFactory = synchronizeFactory(getHttpAdapter, getInterval, getShouldSync, lastCommentId, logger);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qiscus-sdk-core",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
4
4
  "description": "Qiscus Web SDK Core",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -25,7 +25,9 @@
25
25
  "clean": "rimraf dist lib",
26
26
  "preversion": "npm-run-all clean build",
27
27
  "prepublishOnly": "npm-run-all clean build",
28
- "serve": "http-server -p 1234 -c-1 dist"
28
+ "serve": "http-server -p 1234 -c-1 dist",
29
+ "dev:serve": "run-p serve watch",
30
+ "release:patch": "np patch --any-branch --yolo"
29
31
  },
30
32
  "devDependencies": {
31
33
  "@babel/cli": "^7.10.5",
@@ -52,6 +54,7 @@
52
54
  "eslint-plugin-standard": "^4.0.1",
53
55
  "http-server": "^0.12.3",
54
56
  "mocha": "^5.2.0",
57
+ "np": "^7.6.2",
55
58
  "npm-run-all": "^4.1.5",
56
59
  "rimraf": "^2.7.1",
57
60
  "serve": "^12.0.0",
@@ -60,6 +63,7 @@
60
63
  },
61
64
  "dependencies": {
62
65
  "@babel/runtime": "^7.11.2",
66
+ "cuid": "^2.1.8",
63
67
  "date-fns": "^1.30.1",
64
68
  "is_js": "^0.9.0",
65
69
  "lodash.debounce": "^4.0.8",