@sumaris-net/ngx-components 1.8.1 → 1.8.2
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/bundles/sumaris-net.ngx-components.umd.js +44 -54
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +1 -1
- package/esm2015/src/app/core/services/account.service.js +38 -27
- package/esm2015/src/app/shared/services/progress-bar.service.js +1 -1
- package/fesm2015/sumaris-net.ngx-components.js +34 -23
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/account.service.d.ts +2 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -15419,6 +15419,7 @@
|
|
|
15419
15419
|
_this.onChange = new rxjs.Subject();
|
|
15420
15420
|
_this.onAuthTokenChange = new rxjs.Subject();
|
|
15421
15421
|
_this.onAuthBasicChange = new rxjs.Subject();
|
|
15422
|
+
_this._stopWatching$ = new rxjs.Subject();
|
|
15422
15423
|
_this._cache = {
|
|
15423
15424
|
loaded: false,
|
|
15424
15425
|
keypair: null,
|
|
@@ -15945,6 +15946,7 @@
|
|
|
15945
15946
|
if (hadAuthBasic)
|
|
15946
15947
|
this.onAuthBasicChange.next(undefined);
|
|
15947
15948
|
this.onChange.next(undefined);
|
|
15949
|
+
this._stopWatching$.next();
|
|
15948
15950
|
return [2 /*return*/];
|
|
15949
15951
|
}
|
|
15950
15952
|
});
|
|
@@ -16104,13 +16106,18 @@
|
|
|
16104
16106
|
});
|
|
16105
16107
|
});
|
|
16106
16108
|
};
|
|
16107
|
-
AccountService.prototype.
|
|
16109
|
+
AccountService.prototype.watch = function () {
|
|
16108
16110
|
var _this = this;
|
|
16109
16111
|
if (!this._cache.pubkey)
|
|
16110
|
-
|
|
16111
|
-
|
|
16112
|
-
|
|
16113
|
-
|
|
16112
|
+
throw new Error('Not logged in');
|
|
16113
|
+
if (!this.started) {
|
|
16114
|
+
// Wait service ready, then loop
|
|
16115
|
+
return rxjs.from(this.ready())
|
|
16116
|
+
.pipe(operators.switchMap(function () { return _this.watch(); }));
|
|
16117
|
+
}
|
|
16118
|
+
this._stopWatching$.next(); // Stop previous listening
|
|
16119
|
+
console.debug('[account] [WS] Watching changes');
|
|
16120
|
+
return this.graphql.subscribe({
|
|
16114
16121
|
query: AccountSubscriptions.listenChanges,
|
|
16115
16122
|
variables: {
|
|
16116
16123
|
interval: 10
|
|
@@ -16119,57 +16126,40 @@
|
|
|
16119
16126
|
code: ErrorCodes$2.SUBSCRIBE_ACCOUNT_ERROR,
|
|
16120
16127
|
message: 'ERROR.ACCOUNT.SUBSCRIBE_ACCOUNT_ERROR'
|
|
16121
16128
|
}
|
|
16122
|
-
})
|
|
16123
|
-
|
|
16124
|
-
|
|
16125
|
-
|
|
16126
|
-
|
|
16127
|
-
|
|
16128
|
-
|
|
16129
|
-
|
|
16130
|
-
|
|
16131
|
-
|
|
16132
|
-
|
|
16133
|
-
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16137
|
-
|
|
16138
|
-
|
|
16139
|
-
|
|
16140
|
-
|
|
16141
|
-
|
|
16142
|
-
|
|
16143
|
-
|
|
16144
|
-
|
|
16145
|
-
|
|
16146
|
-
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
case 2:
|
|
16155
|
-
if (!(err && +err.code === ServerErrorCodes.UNAUTHORIZED)) return [3 /*break*/, 4];
|
|
16156
|
-
console.info('[account] Account not authorized: force user to logout...', err);
|
|
16157
|
-
return [4 /*yield*/, self.logout()];
|
|
16158
|
-
case 3:
|
|
16159
|
-
_b.sent();
|
|
16160
|
-
return [3 /*break*/, 5];
|
|
16161
|
-
case 4:
|
|
16162
|
-
console.warn('[account] [WS] Received error:', err);
|
|
16163
|
-
_b.label = 5;
|
|
16164
|
-
case 5: return [2 /*return*/];
|
|
16165
|
-
}
|
|
16166
|
-
});
|
|
16167
|
-
}); },
|
|
16168
|
-
complete: function () {
|
|
16169
|
-
console.debug('[account] [WS] Completed');
|
|
16129
|
+
})
|
|
16130
|
+
.pipe(
|
|
16131
|
+
// Stop this pipe next time we call watch()
|
|
16132
|
+
operators.takeUntil(this._stopWatching$), operators.map(function (_b) {
|
|
16133
|
+
var data = _b.data;
|
|
16134
|
+
var _a;
|
|
16135
|
+
if (!data)
|
|
16136
|
+
return;
|
|
16137
|
+
var existingUpdateDate = toDateISOString((_a = _this._data) === null || _a === void 0 ? void 0 : _a.updateDate);
|
|
16138
|
+
if (existingUpdateDate === data.updateDate)
|
|
16139
|
+
return;
|
|
16140
|
+
console.debug("[account] [WS] Detected update on {" + data.updateDate + "}");
|
|
16141
|
+
return exports.Account.fromObject(data);
|
|
16142
|
+
}), operators.filter(isNotNil));
|
|
16143
|
+
};
|
|
16144
|
+
AccountService.prototype.listenChanges = function () {
|
|
16145
|
+
var self = this;
|
|
16146
|
+
var subscription = this.watch()
|
|
16147
|
+
.subscribe({
|
|
16148
|
+
next: function (data) { return self.refresh(); },
|
|
16149
|
+
error: function (err) {
|
|
16150
|
+
if (err && +err.code === ServerErrorCodes.NOT_FOUND) {
|
|
16151
|
+
console.info('[account] Account not exists anymore: force user to logout...', err);
|
|
16152
|
+
self.logout();
|
|
16153
|
+
}
|
|
16154
|
+
else if (err && +err.code === ServerErrorCodes.UNAUTHORIZED) {
|
|
16155
|
+
console.info('[account] Account not authorized: force user to logout...', err);
|
|
16156
|
+
self.logout();
|
|
16157
|
+
}
|
|
16158
|
+
else {
|
|
16159
|
+
console.warn('[account] [WS] Received error:', err);
|
|
16160
|
+
}
|
|
16170
16161
|
}
|
|
16171
16162
|
});
|
|
16172
|
-
// Add log when closing WS
|
|
16173
16163
|
subscription.add(function () { return console.debug('[account] [WS] Stop listening changes'); });
|
|
16174
16164
|
return subscription;
|
|
16175
16165
|
};
|