@sumaris-net/ngx-components 1.21.0-beta17 → 1.21.0-beta18
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 +74 -64
- 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/esm2015/src/app/social/user-event/notification/user-event-notification.component.js +4 -33
- package/esm2015/src/app/social/user-event/user-event.service.js +46 -12
- package/fesm2015/sumaris-net.ngx-components.js +45 -40
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/social/user-event/notification/user-event-notification.component.d.ts +2 -8
- package/src/app/social/user-event/user-event.service.d.ts +4 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -30197,6 +30197,38 @@
|
|
|
30197
30197
|
enumerable: false,
|
|
30198
30198
|
configurable: true
|
|
30199
30199
|
});
|
|
30200
|
+
AbstractUserEventService.prototype.ngOnStart = function () {
|
|
30201
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
30202
|
+
var _this = this;
|
|
30203
|
+
return __generator(this, function (_b) {
|
|
30204
|
+
switch (_b.label) {
|
|
30205
|
+
case 0:
|
|
30206
|
+
// Update component when refresh is need (=login events)
|
|
30207
|
+
this._subscriptions.add(rxjs.merge(this.accountService.onLogin, this.accountService.onLogout)
|
|
30208
|
+
.pipe(
|
|
30209
|
+
// Wait account service ready (can be restarted)
|
|
30210
|
+
operators.mergeMap(function () { return _this.accountService.ready(); }), operators.map(function () { return _this.accountService.isLogin(); }), operators.distinctUntilChanged())
|
|
30211
|
+
.subscribe(function (login) {
|
|
30212
|
+
if (login) {
|
|
30213
|
+
_this.onLogin();
|
|
30214
|
+
}
|
|
30215
|
+
else {
|
|
30216
|
+
_this.onLogout();
|
|
30217
|
+
}
|
|
30218
|
+
}));
|
|
30219
|
+
// First attempt if account is ready
|
|
30220
|
+
return [4 /*yield*/, this.accountService.ready()];
|
|
30221
|
+
case 1:
|
|
30222
|
+
// First attempt if account is ready
|
|
30223
|
+
_b.sent();
|
|
30224
|
+
if (this.accountService.isLogin()) {
|
|
30225
|
+
setTimeout(function () { return _this.onLogin(); });
|
|
30226
|
+
}
|
|
30227
|
+
return [2 /*return*/];
|
|
30228
|
+
}
|
|
30229
|
+
});
|
|
30230
|
+
});
|
|
30231
|
+
};
|
|
30200
30232
|
AbstractUserEventService.prototype.ngOnDestroy = function () {
|
|
30201
30233
|
this._subscriptions.unsubscribe();
|
|
30202
30234
|
};
|
|
@@ -30233,7 +30265,7 @@
|
|
|
30233
30265
|
},
|
|
30234
30266
|
arrayFieldName: 'data',
|
|
30235
30267
|
error: { code: SocialErrorCodes.LOAD_USER_EVENTS_ERROR, message: 'SOCIAL.ERROR.LOAD_USER_EVENTS_ERROR' },
|
|
30236
|
-
fetchPolicy: (options === null || options === void 0 ? void 0 : options.fetchPolicy) ||
|
|
30268
|
+
fetchPolicy: (options === null || options === void 0 ? void 0 : options.fetchPolicy) || 'cache-first'
|
|
30237
30269
|
})
|
|
30238
30270
|
.pipe(operators.map(function (res) {
|
|
30239
30271
|
var data = ((res === null || res === void 0 ? void 0 : res.data) || []).map(function (value) { return _this.processUserEvent(value, _this); });
|
|
@@ -30241,8 +30273,6 @@
|
|
|
30241
30273
|
console.debug("" + _this._logPrefix + data.length + " user events loaded in " + (Date.now() - now) + "ms");
|
|
30242
30274
|
now = null;
|
|
30243
30275
|
}
|
|
30244
|
-
// const unreadCount = this.unreadEvents(data);
|
|
30245
|
-
// this._count$.next(unreadCount);
|
|
30246
30276
|
// Must re-order because of listenChanges result will add new event at the end
|
|
30247
30277
|
data = EntityUtils.sort(data, page.sortBy, page.sortDirection);
|
|
30248
30278
|
return {
|
|
@@ -30266,7 +30296,7 @@
|
|
|
30266
30296
|
AbstractUserEventService.prototype.count = function (filter, options) {
|
|
30267
30297
|
var _a;
|
|
30268
30298
|
return __awaiter(this, void 0, void 0, function () {
|
|
30269
|
-
var res
|
|
30299
|
+
var res;
|
|
30270
30300
|
return __generator(this, function (_b) {
|
|
30271
30301
|
switch (_b.label) {
|
|
30272
30302
|
case 0:
|
|
@@ -30289,10 +30319,7 @@
|
|
|
30289
30319
|
})];
|
|
30290
30320
|
case 1:
|
|
30291
30321
|
res = _b.sent();
|
|
30292
|
-
|
|
30293
|
-
// update count
|
|
30294
|
-
this._count$.next(total);
|
|
30295
|
-
return [2 /*return*/, total];
|
|
30322
|
+
return [2 /*return*/, res.total];
|
|
30296
30323
|
}
|
|
30297
30324
|
});
|
|
30298
30325
|
});
|
|
@@ -30356,8 +30383,6 @@
|
|
|
30356
30383
|
query: withContent ? _this.queries.loadAllWithContent : _this.queries.loadAll,
|
|
30357
30384
|
data: updatedData
|
|
30358
30385
|
});
|
|
30359
|
-
// update count
|
|
30360
|
-
// this._count$.next(this.unreadEvents(updatedData));
|
|
30361
30386
|
return updatedData;
|
|
30362
30387
|
}));
|
|
30363
30388
|
};
|
|
@@ -30523,6 +30548,33 @@
|
|
|
30523
30548
|
this.listeners.push(listener);
|
|
30524
30549
|
};
|
|
30525
30550
|
/* -- protected methods -- */
|
|
30551
|
+
AbstractUserEventService.prototype.onLogin = function () {
|
|
30552
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
30553
|
+
var count;
|
|
30554
|
+
var _this = this;
|
|
30555
|
+
return __generator(this, function (_b) {
|
|
30556
|
+
switch (_b.label) {
|
|
30557
|
+
case 0: return [4 /*yield*/, this.count(undefined)];
|
|
30558
|
+
case 1:
|
|
30559
|
+
count = _b.sent();
|
|
30560
|
+
if (this._debug)
|
|
30561
|
+
console.debug(this._logPrefix + "Receiving user events count", count);
|
|
30562
|
+
// Update count
|
|
30563
|
+
this._count$.next(count);
|
|
30564
|
+
// Then listen changes
|
|
30565
|
+
this._listenSubscription = this.listenCountChanges(undefined).subscribe(function (count) {
|
|
30566
|
+
if (_this._debug)
|
|
30567
|
+
console.debug(_this._logPrefix + "Receiving new user events count", count);
|
|
30568
|
+
});
|
|
30569
|
+
return [2 /*return*/];
|
|
30570
|
+
}
|
|
30571
|
+
});
|
|
30572
|
+
});
|
|
30573
|
+
};
|
|
30574
|
+
AbstractUserEventService.prototype.onLogout = function () {
|
|
30575
|
+
var _a;
|
|
30576
|
+
(_a = this._listenSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
30577
|
+
};
|
|
30526
30578
|
AbstractUserEventService.prototype.processUserEvent = function (source, that) {
|
|
30527
30579
|
var e_2, _b;
|
|
30528
30580
|
that = that || this;
|
|
@@ -31015,11 +31067,10 @@
|
|
|
31015
31067
|
};
|
|
31016
31068
|
|
|
31017
31069
|
var UserEventNotificationComponent = /** @class */ (function () {
|
|
31018
|
-
function UserEventNotificationComponent(userEventService, accountService, popoverController
|
|
31070
|
+
function UserEventNotificationComponent(userEventService, accountService, popoverController) {
|
|
31019
31071
|
this.userEventService = userEventService;
|
|
31020
31072
|
this.accountService = accountService;
|
|
31021
31073
|
this.popoverController = popoverController;
|
|
31022
|
-
this.cd = cd;
|
|
31023
31074
|
this.debug = false;
|
|
31024
31075
|
this.titleI18n = 'SOCIAL.USER_EVENT.NOTIFICATION.TITLE';
|
|
31025
31076
|
this.disabled = false;
|
|
@@ -31038,26 +31089,17 @@
|
|
|
31038
31089
|
return __awaiter(this, void 0, void 0, function () {
|
|
31039
31090
|
var _this = this;
|
|
31040
31091
|
return __generator(this, function (_b) {
|
|
31041
|
-
|
|
31042
|
-
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
this.disabled = true;
|
|
31046
|
-
return [2 /*return*/];
|
|
31047
|
-
}
|
|
31048
|
-
return [4 /*yield*/, this.accountService.ready()];
|
|
31049
|
-
case 1:
|
|
31050
|
-
_b.sent();
|
|
31051
|
-
// listen login/logout
|
|
31052
|
-
this.accountService.onLogin.subscribe(function (account) { return _this.onLogin(account); });
|
|
31053
|
-
this.accountService.onLogout.subscribe(function () { return _this.onLogout(); });
|
|
31054
|
-
// Subscribe to read event
|
|
31055
|
-
this._readEvent.subscribe(function (value) {
|
|
31056
|
-
// default: mark event as read
|
|
31057
|
-
_this.userEventService.markAsRead(value);
|
|
31058
|
-
});
|
|
31059
|
-
return [2 /*return*/];
|
|
31092
|
+
if (isNil(this.userEventService)) {
|
|
31093
|
+
console.warn(this._logPrefix + "No service injected");
|
|
31094
|
+
this.disabled = true;
|
|
31095
|
+
return [2 /*return*/];
|
|
31060
31096
|
}
|
|
31097
|
+
// Subscribe to read event
|
|
31098
|
+
this._readEvent.subscribe(function (value) {
|
|
31099
|
+
// default: mark event as read
|
|
31100
|
+
_this.userEventService.markAsRead(value);
|
|
31101
|
+
});
|
|
31102
|
+
return [2 /*return*/];
|
|
31061
31103
|
});
|
|
31062
31104
|
});
|
|
31063
31105
|
};
|
|
@@ -31093,37 +31135,6 @@
|
|
|
31093
31135
|
if (this.debug) {
|
|
31094
31136
|
console.debug(this._logPrefix + "Destroying");
|
|
31095
31137
|
}
|
|
31096
|
-
this.onLogout();
|
|
31097
|
-
};
|
|
31098
|
-
UserEventNotificationComponent.prototype.onLogin = function (account) {
|
|
31099
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
31100
|
-
var count;
|
|
31101
|
-
var _this = this;
|
|
31102
|
-
return __generator(this, function (_b) {
|
|
31103
|
-
switch (_b.label) {
|
|
31104
|
-
case 0: return [4 /*yield*/, this.userEventService.count(undefined)];
|
|
31105
|
-
case 1:
|
|
31106
|
-
count = _b.sent();
|
|
31107
|
-
if (this.debug)
|
|
31108
|
-
console.debug(this._logPrefix + "Receiving user events count", count);
|
|
31109
|
-
this.markForCheck();
|
|
31110
|
-
// Then listen changes
|
|
31111
|
-
this._listenSubscription = this.userEventService.listenCountChanges(undefined).subscribe(function (count) {
|
|
31112
|
-
if (_this.debug)
|
|
31113
|
-
console.debug(_this._logPrefix + "Receiving new user events count", count);
|
|
31114
|
-
_this.markForCheck();
|
|
31115
|
-
});
|
|
31116
|
-
return [2 /*return*/];
|
|
31117
|
-
}
|
|
31118
|
-
});
|
|
31119
|
-
});
|
|
31120
|
-
};
|
|
31121
|
-
UserEventNotificationComponent.prototype.onLogout = function () {
|
|
31122
|
-
var _a;
|
|
31123
|
-
(_a = this._listenSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
31124
|
-
};
|
|
31125
|
-
UserEventNotificationComponent.prototype.markForCheck = function () {
|
|
31126
|
-
this.cd.markForCheck();
|
|
31127
31138
|
};
|
|
31128
31139
|
return UserEventNotificationComponent;
|
|
31129
31140
|
}());
|
|
@@ -31138,8 +31149,7 @@
|
|
|
31138
31149
|
UserEventNotificationComponent.ctorParameters = function () { return [
|
|
31139
31150
|
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [UserEventServiceToken,] }] },
|
|
31140
31151
|
{ type: AccountService },
|
|
31141
|
-
{ type: i1$5.PopoverController }
|
|
31142
|
-
{ type: i0.ChangeDetectorRef }
|
|
31152
|
+
{ type: i1$5.PopoverController }
|
|
31143
31153
|
]; };
|
|
31144
31154
|
UserEventNotificationComponent.propDecorators = {
|
|
31145
31155
|
debug: [{ type: i0.Input }],
|