@sumaris-net/ngx-components 1.21.0-beta2 → 1.21.0-beta20

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.
Files changed (26) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +459 -152
  2. package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
  3. package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
  4. package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
  5. package/esm2015/src/app/core/menu/menu.component.js +2 -9
  6. package/esm2015/src/app/social/job/job.service.js +1 -2
  7. package/esm2015/src/app/social/user-event/notification/user-event-notification.component.js +23 -31
  8. package/esm2015/src/app/social/user-event/notification/user-event-notification.list.js +47 -8
  9. package/esm2015/src/app/social/user-event/testing/user-event.testing.service.js +73 -0
  10. package/esm2015/src/app/social/user-event/user-event.model.js +1 -1
  11. package/esm2015/src/app/social/user-event/user-event.module.js +6 -1
  12. package/esm2015/src/app/social/user-event/user-event.service.js +182 -59
  13. package/esm2015/sumaris-net.ngx-components.js +8 -7
  14. package/fesm2015/sumaris-net.ngx-components.js +309 -99
  15. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  16. package/package.json +1 -1
  17. package/src/app/social/user-event/notification/user-event-notification.component.d.ts +5 -8
  18. package/src/app/social/user-event/notification/user-event-notification.list.d.ts +18 -8
  19. package/src/app/social/user-event/testing/user-event.testing.service.d.ts +35 -0
  20. package/src/app/social/user-event/user-event.model.d.ts +1 -1
  21. package/src/app/social/user-event/user-event.service.d.ts +26 -10
  22. package/src/assets/i18n/en.json +2 -1
  23. package/src/assets/i18n/fr.json +2 -1
  24. package/src/theme/_ngx-components.scss +1 -0
  25. package/sumaris-net.ngx-components.d.ts +7 -6
  26. package/sumaris-net.ngx-components.metadata.json +1 -1
@@ -24386,9 +24386,6 @@
24386
24386
  this._subscription = new rxjs.Subscription();
24387
24387
  this.loading = true;
24388
24388
  this.isLogin = false;
24389
- // showUserEventNotification: boolean;
24390
- // showJobProgression: boolean;
24391
- // jobProgressionOptions: JobProgressionOptions;
24392
24389
  this.$items = new rxjs.BehaviorSubject(undefined);
24393
24390
  this.id = 'menu';
24394
24391
  this.menuId = 'left';
@@ -24413,10 +24410,6 @@
24413
24410
  case 2:
24414
24411
  // Wait platform started
24415
24412
  _b.sent();
24416
- // Init social options
24417
- // this.showUserEventNotification = toBoolean(this.socialModuleOptions?.showUserEventNotification, false);
24418
- // this.showJobProgression = toBoolean(this.socialModuleOptions?.showJobProgression, false);
24419
- // this.jobProgressionOptions = this.socialModuleOptions?.jobProgressionOptions;
24420
24413
  // Listen to menu service event
24421
24414
  this.menuService.splitPaneWhen
24422
24415
  .subscribe(function (value) { return _this.setSplitPaneWhen(value); });
@@ -24756,7 +24749,7 @@
24756
24749
  MenuComponent.decorators = [
24757
24750
  { type: i0.Component, args: [{
24758
24751
  selector: 'app-menu',
24759
- template: "<ion-split-pane #splitPane [contentId]=\"contentId\" (swiperight)=\"onSwipeRight($event)\">\n\n <ion-menu [id]=\"id\" [menuId]=\"menuId\" contentId=\"menu-content\">\n <ion-header>\n\n <ion-toolbar @fadeInAnimation *ngIf=\"isLogin; else notLogin\" class=\"ion-toolbar-top\">\n <ion-grid>\n <ion-row>\n <ion-col size=\"4\">\n <button type=\"button\" mat-flat-button\n class=\"user-avatar\" [class.primary]=\"!accountAvatar\"\n [style.background-image]=\"'url('+(accountAvatar||'./assets/img/person.png')+')'\"\n [routerLink]=\"['/account']\"\n routerDirection=\"root\"\n routerLinkActive=\"ion-color-primary\"\n (click)=\"close()\">\n </button>\n </ion-col>\n <ion-col size=\"8\" class=\"user-logo\">\n <img *ngIf=\"logo\" src=\"{{logo}}\" [title]=\"'APP_NAME'|translate: {appName: appName}\" width=\"108px;\"/>\n <span *ngIf=\"!logo\" width=\"108px;\">{{appName}}</span>\n </ion-col>\n </ion-row>\n <ion-row class=\"ion-no-padding\">\n\n <button mat-button type=\"button\"\n [routerLink]=\"['/account']\"\n routerDirection=\"root\"\n routerLinkActive=\"ion-color-primary\"\n (click)=\"close()\">\n <ion-label color=\"primary\" class=\"ion-text-wrap ion-text-start\">\n <h3 class=\"no-margin username\">\n <b>{{accountName}}</b>\n </h3>\n <h4>{{accountEmail}}</h4>\n </ion-label>\n </button>\n\n<!-- todo ajouter ici les 2 composants du module social -->\n\n </ion-row>\n </ion-grid>\n\n </ion-toolbar>\n\n <!-- User not logged -->\n <ng-template #notLogin>\n <mat-toolbar class=\"ion-padding\" @fadeInAnimation\n style=\"height: unset; display: block; margin: auto; text-align: center;\">\n <img *ngIf=\"logo\" src=\"{{logo}}\" [title]=\"'APP_NAME'|translate: {appName: appName}\" width=\"150px;\">\n <span *ngIf=\"!logo\" style=\"width: 150px\">{{appName}}</span>\n </mat-toolbar>\n </ng-template>\n </ion-header>\n\n <ion-content [class.has-user-header]=\"isLogin\">\n\n <ion-list lines=\"none\">\n <ion-menu-toggle auto-hide=\"false\"\n [class.flex-spacer]=\"item.cssClass == 'flex-spacer'\"\n *ngFor=\"let item of $items | async\">\n\n <!-- link -->\n <ion-item *ngIf=\"!loading && item.path\"\n @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}} text-1x\"\n tappable\n [routerLink]=\"item.path\"\n routerDirection=\"root\"\n routerLinkActive=\"selected\"\n [routerLinkActiveOptions]=\"{exact: (item.path === '/')}\">\n <ion-icon slot=\"start\" *ngIf=\"item.icon\" [name]=\"item.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"item.matIcon\">{{item.matIcon}}</mat-icon>\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item>\n\n <!-- action -->\n <ion-item *ngIf=\"!loading && item.action\"\n @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}} text-1x\"\n tappable\n (click)=\"doAction(item.action, $event)\">\n <ion-icon slot=\"start\" *ngIf=\"item.icon\" [name]=\"item.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"item.matIcon\">{{item.matIcon}}</mat-icon>\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item>\n\n <!-- divider -->\n <ion-item-divider @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}}\"\n *ngIf=\"!loading && !item.path && !item.action\">\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item-divider>\n\n </ion-menu-toggle>\n </ion-list>\n </ion-content>\n\n <ion-footer class=\"hidden-xs hidden-sm\">\n <ion-toolbar>\n\n <ion-buttons slot=\"start\">\n <ion-button mat-icon-button color=\"accent\" (click)=\"openAboutModal($event)\">\n <mat-icon slot=\"icon-only\">help_outline</mat-icon>\n </ion-button>\n </ion-buttons>\n\n <ion-title (click)=\"openAboutModal($event)\" color=\"medium\">\n {{'MENU.FOOTER_VERSION_ABOUT'| translate: {version: appVersion} }}\n </ion-title>\n\n <ion-buttons slot=\"end\">\n <button mat-icon-button color=\"accent\" (click)=\"toggleSplitPaneShow($event)\"\n class=\"hidden-xs hidden-sm hidden-md\"\n [title]=\"(splitPane.when ? 'COMMON.BTN_HIDE_MENU' : 'COMMON.BTN_SHOW_MENU') |translate\">\n <mat-icon><span>{{splitPane.when ? '&#xab;' : '&#xbb;'}}</span></mat-icon>\n </button>\n </ion-buttons>\n </ion-toolbar>\n </ion-footer>\n\n </ion-menu>\n\n <ng-content></ng-content>\n\n</ion-split-pane>\n",
24752
+ template: "<ion-split-pane #splitPane [contentId]=\"contentId\" (swiperight)=\"onSwipeRight($event)\">\n\n <ion-menu [id]=\"id\" [menuId]=\"menuId\" contentId=\"menu-content\">\n <ion-header>\n\n <ion-toolbar @fadeInAnimation *ngIf=\"isLogin; else notLogin\" class=\"ion-toolbar-top\">\n <ion-grid>\n <ion-row>\n <ion-col size=\"4\">\n <button type=\"button\" mat-flat-button\n class=\"user-avatar\" [class.primary]=\"!accountAvatar\"\n [style.background-image]=\"'url('+(accountAvatar||'./assets/img/person.png')+')'\"\n [routerLink]=\"['/account']\"\n routerDirection=\"root\"\n routerLinkActive=\"ion-color-primary\"\n (click)=\"close()\">\n </button>\n </ion-col>\n <ion-col size=\"8\" class=\"user-logo\">\n <img *ngIf=\"logo\" src=\"{{logo}}\" [title]=\"'APP_NAME'|translate: {appName: appName}\" width=\"108px;\"/>\n <span *ngIf=\"!logo\" width=\"108px;\">{{appName}}</span>\n </ion-col>\n </ion-row>\n <ion-row class=\"ion-no-padding\">\n\n <button mat-button type=\"button\"\n [routerLink]=\"['/account']\"\n routerDirection=\"root\"\n routerLinkActive=\"ion-color-primary\"\n (click)=\"close()\">\n <ion-label color=\"primary\" class=\"ion-text-wrap ion-text-start\">\n <h3 class=\"no-margin username\">\n <b>{{accountName}}</b>\n </h3>\n <h4>{{accountEmail}}</h4>\n </ion-label>\n </button>\n\n<!-- todo ajouter ici les 2 composants du module social ??? -->\n\n </ion-row>\n </ion-grid>\n\n </ion-toolbar>\n\n <!-- User not logged -->\n <ng-template #notLogin>\n <mat-toolbar class=\"ion-padding\" @fadeInAnimation\n style=\"height: unset; display: block; margin: auto; text-align: center;\">\n <img *ngIf=\"logo\" src=\"{{logo}}\" [title]=\"'APP_NAME'|translate: {appName: appName}\" width=\"150px;\">\n <span *ngIf=\"!logo\" style=\"width: 150px\">{{appName}}</span>\n </mat-toolbar>\n </ng-template>\n </ion-header>\n\n <ion-content [class.has-user-header]=\"isLogin\">\n\n <ion-list lines=\"none\">\n <ion-menu-toggle auto-hide=\"false\"\n [class.flex-spacer]=\"item.cssClass == 'flex-spacer'\"\n *ngFor=\"let item of $items | async\">\n\n <!-- link -->\n <ion-item *ngIf=\"!loading && item.path\"\n @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}} text-1x\"\n tappable\n [routerLink]=\"item.path\"\n routerDirection=\"root\"\n routerLinkActive=\"selected\"\n [routerLinkActiveOptions]=\"{exact: (item.path === '/')}\">\n <ion-icon slot=\"start\" *ngIf=\"item.icon\" [name]=\"item.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"item.matIcon\">{{item.matIcon}}</mat-icon>\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item>\n\n <!-- action -->\n <ion-item *ngIf=\"!loading && item.action\"\n @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}} text-1x\"\n tappable\n (click)=\"doAction(item.action, $event)\">\n <ion-icon slot=\"start\" *ngIf=\"item.icon\" [name]=\"item.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"item.matIcon\">{{item.matIcon}}</mat-icon>\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item>\n\n <!-- divider -->\n <ion-item-divider @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}}\"\n *ngIf=\"!loading && !item.path && !item.action\">\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item-divider>\n\n </ion-menu-toggle>\n </ion-list>\n </ion-content>\n\n <ion-footer class=\"hidden-xs hidden-sm\">\n <ion-toolbar>\n\n <ion-buttons slot=\"start\">\n <ion-button mat-icon-button color=\"accent\" (click)=\"openAboutModal($event)\">\n <mat-icon slot=\"icon-only\">help_outline</mat-icon>\n </ion-button>\n </ion-buttons>\n\n <ion-title (click)=\"openAboutModal($event)\" color=\"medium\">\n {{'MENU.FOOTER_VERSION_ABOUT'| translate: {version: appVersion} }}\n </ion-title>\n\n <ion-buttons slot=\"end\">\n <button mat-icon-button color=\"accent\" (click)=\"toggleSplitPaneShow($event)\"\n class=\"hidden-xs hidden-sm hidden-md\"\n [title]=\"(splitPane.when ? 'COMMON.BTN_HIDE_MENU' : 'COMMON.BTN_SHOW_MENU') |translate\">\n <mat-icon><span>{{splitPane.when ? '&#xab;' : '&#xbb;'}}</span></mat-icon>\n </button>\n </ion-buttons>\n </ion-toolbar>\n </ion-footer>\n\n </ion-menu>\n\n <ng-content></ng-content>\n\n</ion-split-pane>\n",
24760
24753
  animations: [fadeInAnimation],
24761
24754
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
24762
24755
  styles: ["ion-menu{--ion-item-background:transparent;--ion-item-divider-background:transparent;--ion-item-icon-color:var(--ion-color-primary-tint);--ion-item-text-color:var(--ion-color-primary-tint);--ion-item-background-selected:var(--ion-color-secondary100);--ion-item-text-color-selected:var(--ion-color-primary);--ion-item-icon-color-selected:var(--ion-color-primary);--ion-item-text-color-disable:var(--ion-color-medium);--ion-item-icon-color-disable:var(--ion-color-medium)}ion-menu ion-header ion-text{color:var(--ion-color-primary)}ion-menu ion-header .user-avatar{background-size:cover;background-repeat:no-repeat;background-position:50%;background-color:var(--ion-color-secondary);border:1px solid var(--ion-color-primary);overflow:hidden!important;font-size:var(--avatar-size,60px)!important;line-height:var(--avatar-size,60px);height:var(--avatar-size,60px)!important;width:var(--avatar-size,60px)!important;border-radius:50%;display:inline-block}ion-menu ion-header .user-logo{text-align:right}ion-menu ion-header .user-logo img{max-width:120px;max-height:var(--avatar-size,60px);width:auto}ion-menu ion-header .username{padding-top:0;margin-top:0;margin-bottom:0;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}ion-menu ion-header button[mat-button]{padding:0;text-align:start!important;width:100%}ion-menu .scroll-content{margin-top:79px!important}ion-menu .has-user-header .scroll-content{margin-top:188px!important}ion-menu ion-content.has-profile-header{--offset-top:188px}ion-menu ion-content.no-profile-header{--offset-top:79px}ion-menu ion-content ion-list{min-height:100%;display:flex;flex-direction:column;justify-content:flex-start}ion-menu ion-content ion-list ion-menu-toggle.flex-spacer{flex:1 1 auto;display:flex;flex-direction:column;justify-content:flex-end}ion-menu ion-content ion-list ion-item.primary{--ion-item-icon-color:var(--ion-color-primary-tint);--ion-item-text-color:var(--ion-color-primary-tint)}ion-menu ion-content ion-list ion-item.secondary{--ion-item-icon-color:var(--ion-color-secondary-tint);--ion-item-text-color:var(--ion-color-secondary-tint)}ion-menu ion-content ion-list ion-item.tertiary{--ion-item-icon-color:var(--ion-color-tertiary-tint);--ion-item-text-color:var(--ion-color-tertiary-tint)}ion-menu ion-content ion-list ion-item.danger{--ion-item-icon-color:var(--ion-color-danger-tint);--ion-item-text-color:var(--ion-color-danger-tint)}ion-menu ion-content ion-list ion-item.medium{--ion-item-icon-color:var(--ion-color-medium-shade);--ion-item-text-color:var(--ion-color-medium-shade)}ion-menu ion-content ion-list ion-item.dark{--ion-item-icon-color:var(--ion-color-dark-tint);--ion-item-text-color:var(--ion-color-dark-tint)}ion-menu ion-content ion-list ion-item ion-icon,ion-menu ion-content ion-list ion-item mat-icon{color:var(--ion-item-icon-color)!important;fill:currentColor;stroke:currentColor}ion-menu ion-content ion-list ion-item ion-label,ion-menu ion-content ion-list ion-item ion-text{color:var(--ion-item-text-color)!important}ion-menu ion-content ion-list ion-item.selected{background-color:var(--ion-item-background-selected)!important;--color-hover:var(--ion-item-background-selected)!important}ion-menu ion-content ion-list ion-item.selected ion-icon,ion-menu ion-content ion-list ion-item.selected mat-icon{color:var(--ion-item-icon-color-selected)!important;fill:currentColor;stroke:currentColor}ion-menu ion-content ion-list ion-item.selected ion-label,ion-menu ion-content ion-list ion-item.selected ion-text{color:var(--ion-item-text-color-selected)!important}ion-menu ion-content ion-list ion-item.selected:hover{--color-hover:var(--ion-item-background-selected)!important;--ion-item-icon-color-selected:var(--ion-item-icon-color)!important;--ion-item-text-color-selected:var(--ion-item-text-color)!important}ion-menu ion-footer{display:block!important}ion-menu ion-footer ion-toolbar ion-title{cursor:pointer;font-size:12pt;font-weight:400;text-align:center;padding:0 8px}ion-menu ion-footer ion-toolbar ion-button{--width:40px}@media screen and (max-width:767px){ion-menu ion-footer{display:none!important;visibility:hidden!important}}@media screen and (min-width:768px){ion-menu ion-scroll{overflow-y:auto!important}ion-menu .user-avatar{font-size:var(--avatar-size,80px)!important;line-height:var(--avatar-size,80px);height:var(--avatar-size,80px)!important;width:var(--avatar-size,80px)!important}ion-menu .user-logo img{max-height:var(--avatar-size,80px)}}"]
@@ -30179,13 +30172,12 @@
30179
30172
  var UserEventServiceToken = new i0.InjectionToken('UserEventService');
30180
30173
  var AbstractUserEventService = /** @class */ (function (_super) {
30181
30174
  __extends(AbstractUserEventService, _super);
30182
- function AbstractUserEventService(graphql, accountService, network, translate, toastController, queries, mutations, subscriptions, environment) {
30175
+ function AbstractUserEventService(graphql, accountService, network, translate, queries, mutations, subscriptions, environment) {
30183
30176
  var _this = _super.call(this, graphql, environment) || this;
30184
30177
  _this.graphql = graphql;
30185
30178
  _this.accountService = accountService;
30186
30179
  _this.network = network;
30187
30180
  _this.translate = translate;
30188
- _this.toastController = toastController;
30189
30181
  _this.queries = queries;
30190
30182
  _this.mutations = mutations;
30191
30183
  _this.subscriptions = subscriptions;
@@ -30196,22 +30188,6 @@
30196
30188
  _this._logPrefix = '[user-event-service] ';
30197
30189
  // For DEV only
30198
30190
  _this._debug = !(environment === null || environment === void 0 ? void 0 : environment.production);
30199
- // listen login/logout
30200
- _this._subscriptions.add(accountService.onLogin.subscribe(function () { return __awaiter(_this, void 0, void 0, function () {
30201
- var count;
30202
- return __generator(this, function (_b) {
30203
- switch (_b.label) {
30204
- case 0: return [4 /*yield*/, this.count(this.defaultFilter())];
30205
- case 1:
30206
- count = _b.sent();
30207
- if (count && this._debug) {
30208
- console.debug(this._logPrefix + "Received " + count + " unread notifications");
30209
- }
30210
- this._count$.next(count);
30211
- return [2 /*return*/];
30212
- }
30213
- });
30214
- }); }));
30215
30191
  return _this;
30216
30192
  }
30217
30193
  Object.defineProperty(AbstractUserEventService.prototype, "userEventCount", {
@@ -30221,6 +30197,38 @@
30221
30197
  enumerable: false,
30222
30198
  configurable: true
30223
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
+ };
30224
30232
  AbstractUserEventService.prototype.ngOnDestroy = function () {
30225
30233
  this._subscriptions.unsubscribe();
30226
30234
  };
@@ -30231,13 +30239,15 @@
30231
30239
  var _this = this;
30232
30240
  var _a;
30233
30241
  var now = this._debug && Date.now();
30234
- //if (this._debug)
30242
+ if (!filter) {
30243
+ filter = this.defaultFilter();
30244
+ }
30235
30245
  console.debug(this._logPrefix + "Loading user events...", filter);
30236
30246
  filter = this.asFilter(filter);
30237
30247
  // Force recipient to current issuer, if not admin and not specified
30238
- if (isEmptyArray(filter.recipients) || !this.accountService.isAdmin()) {
30248
+ if (isEmptyArray(filter === null || filter === void 0 ? void 0 : filter.recipients) || !this.accountService.isAdmin()) {
30239
30249
  var recipient = this.defaultRecipient();
30240
- if (!((_a = filter.recipients) === null || _a === void 0 ? void 0 : _a.includes(recipient))) {
30250
+ if (!((_a = filter === null || filter === void 0 ? void 0 : filter.recipients) === null || _a === void 0 ? void 0 : _a.includes(recipient))) {
30241
30251
  console.warn('[user-events-service] Force user event filter.recipient=' + recipient);
30242
30252
  filter.recipients = [recipient];
30243
30253
  }
@@ -30247,23 +30257,27 @@
30247
30257
  queryName: withContent ? 'LoadAllWithContent' : 'LoadAll',
30248
30258
  query: withContent ? this.queries.loadAllWithContent : this.queries.loadAll,
30249
30259
  variables: {
30250
- page: Object.assign({ sortBy: 'updateDate', sortDirection: 'desc' }, page),
30260
+ page: Object.assign(Object.assign({ sortBy: 'creationDate' }, page), {
30261
+ // @ts-ignore
30262
+ sortDirection: (page.sortDirection || 'desc').toUpperCase()
30263
+ }),
30251
30264
  filter: filter && filter.asPodObject()
30252
30265
  },
30253
30266
  arrayFieldName: 'data',
30254
30267
  error: { code: SocialErrorCodes.LOAD_USER_EVENTS_ERROR, message: 'SOCIAL.ERROR.LOAD_USER_EVENTS_ERROR' },
30255
- fetchPolicy: (options === null || options === void 0 ? void 0 : options.fetchPolicy) || "cache-first"
30268
+ fetchPolicy: (options === null || options === void 0 ? void 0 : options.fetchPolicy) || 'cache-first'
30256
30269
  })
30257
30270
  .pipe(operators.map(function (res) {
30258
- var data = ((res === null || res === void 0 ? void 0 : res.data) || []).map(_this.processUserEvent);
30271
+ var data = ((res === null || res === void 0 ? void 0 : res.data) || []).map(function (value) { return _this.processUserEvent(value, _this); });
30259
30272
  if (now) {
30260
30273
  console.debug("" + _this._logPrefix + data.length + " user events loaded in " + (Date.now() - now) + "ms");
30261
30274
  now = null;
30262
30275
  }
30263
- var unreadCount = _this.unreadEvents(data);
30276
+ // Must re-order because of listenChanges result will add new event at the end
30277
+ data = EntityUtils.sort(data, page.sortBy, page.sortDirection);
30264
30278
  return {
30265
30279
  data: data,
30266
- total: toNumber(res === null || res === void 0 ? void 0 : res.total, unreadCount)
30280
+ total: toNumber(res === null || res === void 0 ? void 0 : res.total, data.length)
30267
30281
  };
30268
30282
  }));
30269
30283
  };
@@ -30291,7 +30305,7 @@
30291
30305
  return [2 /*return*/, undefined];
30292
30306
  }
30293
30307
  if (!filter)
30294
- throw new Error("Missing argument 'filter'");
30308
+ filter = this.defaultFilter();
30295
30309
  filter = this.asFilter(filter);
30296
30310
  if (this._debug)
30297
30311
  console.debug(this._logPrefix + "Counting user events with filter:", filter);
@@ -30310,6 +30324,34 @@
30310
30324
  });
30311
30325
  });
30312
30326
  };
30327
+ AbstractUserEventService.prototype.listenCountChanges = function (filter, options) {
30328
+ var _this = this;
30329
+ if (!this.subscriptions.listenCountChanges) {
30330
+ console.warn(this._logPrefix + "Subscription query 'listenCountChanges' not provided, skip.");
30331
+ return rxjs.of();
30332
+ }
30333
+ if (!filter)
30334
+ filter = this.defaultFilter();
30335
+ filter = this.asFilter(filter);
30336
+ if (this._debug)
30337
+ console.debug(this._logPrefix + "[WS] Listening count changes for user events with filter:", filter);
30338
+ return this.graphql.subscribe({
30339
+ query: this.subscriptions.listenCountChanges,
30340
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
30341
+ variables: { filter: filter.asPodObject(), interval: toNumber(options === null || options === void 0 ? void 0 : options.interval, 10) },
30342
+ error: {
30343
+ code: SocialErrorCodes.SUBSCRIBE_USER_EVENTS_ERROR,
30344
+ message: 'SOCIAL.ERROR.SUBSCRIBE_USER_EVENTS_ERROR'
30345
+ }
30346
+ }).pipe(operators.map(function (_b) {
30347
+ var total = _b.total;
30348
+ if (total && _this._debug)
30349
+ console.debug(_this._logPrefix + "Received new user events count:", total);
30350
+ // update count
30351
+ _this._count$.next(total);
30352
+ return total;
30353
+ }));
30354
+ };
30313
30355
  AbstractUserEventService.prototype.listenChanges = function (filter, options) {
30314
30356
  var _this = this;
30315
30357
  var _a;
@@ -30318,7 +30360,7 @@
30318
30360
  return rxjs.of();
30319
30361
  }
30320
30362
  if (!filter)
30321
- throw new Error("Missing argument 'filter'");
30363
+ filter = this.defaultFilter();
30322
30364
  filter = this.asFilter(filter);
30323
30365
  var withContent = (options === null || options === void 0 ? void 0 : options.withContent) === true;
30324
30366
  if (this._debug)
@@ -30335,14 +30377,12 @@
30335
30377
  var data = _b.data;
30336
30378
  if (data && _this._debug)
30337
30379
  console.debug(_this._logPrefix + "Received new user events:", data);
30338
- var updatedData = data === null || data === void 0 ? void 0 : data.map(_this.processUserEvent);
30380
+ var updatedData = data === null || data === void 0 ? void 0 : data.map(function (value) { return _this.processUserEvent(value, _this); });
30339
30381
  // Update cache
30340
30382
  _this.insertIntoMutableCachedQueries(_this.graphql.cache, {
30341
30383
  query: withContent ? _this.queries.loadAllWithContent : _this.queries.loadAll,
30342
30384
  data: updatedData
30343
30385
  });
30344
- // update count
30345
- _this._count$.next(_this.unreadEvents(updatedData));
30346
30386
  return updatedData;
30347
30387
  }));
30348
30388
  };
@@ -30403,13 +30443,21 @@
30403
30443
  };
30404
30444
  AbstractUserEventService.prototype.save = function (entity, options) {
30405
30445
  return __awaiter(this, void 0, void 0, function () {
30406
- var isNew, json, now;
30446
+ var allData, withContent, json, now;
30407
30447
  var _this = this;
30408
30448
  return __generator(this, function (_b) {
30409
30449
  switch (_b.label) {
30410
30450
  case 0:
30451
+ if (!!this.mutations.save) return [3 /*break*/, 2];
30452
+ if (!this.mutations.saveAll)
30453
+ throw new Error('Not implemented');
30454
+ return [4 /*yield*/, this.saveAll([entity], options)];
30455
+ case 1:
30456
+ allData = _b.sent();
30457
+ return [2 /*return*/, allData === null || allData === void 0 ? void 0 : allData[0]];
30458
+ case 2:
30411
30459
  this.fillDefaultProperties(entity);
30412
- isNew = isNil(entity.id);
30460
+ withContent = !!entity.content;
30413
30461
  json = entity.asObject();
30414
30462
  now = Date.now();
30415
30463
  if (this._debug)
@@ -30429,75 +30477,167 @@
30429
30477
  console.debug(_this._logPrefix + "User event saved in " + (Date.now() - now) + "ms", entity);
30430
30478
  _this.copyIdAndUpdateDate(savedEntity, entity);
30431
30479
  // Add to cache
30432
- if (isNew) {
30433
- _this.insertIntoMutableCachedQueries(proxy, {
30434
- query: _this.queries.loadAll,
30435
- data: Object.assign(Object.assign({}, savedEntity), { content: null })
30436
- });
30480
+ if (withContent) {
30437
30481
  _this.insertIntoMutableCachedQueries(proxy, {
30438
30482
  query: _this.queries.loadAllWithContent,
30439
30483
  data: savedEntity
30440
30484
  });
30441
30485
  }
30486
+ else {
30487
+ _this.insertIntoMutableCachedQueries(proxy, {
30488
+ query: _this.queries.loadAll,
30489
+ data: Object.assign(Object.assign({}, savedEntity), { content: null })
30490
+ });
30491
+ }
30442
30492
  }
30443
30493
  }
30444
30494
  })];
30445
- case 1:
30495
+ case 3:
30446
30496
  _b.sent();
30447
30497
  return [2 /*return*/, entity];
30448
30498
  }
30449
30499
  });
30450
30500
  });
30451
30501
  };
30452
- AbstractUserEventService.prototype.saveAll = function (data, opts) {
30453
- var _this = this;
30454
- return Promise.all(data
30455
- .map(function (entity) { return _this.save(entity, opts); }));
30502
+ AbstractUserEventService.prototype.saveAll = function (entities, opts) {
30503
+ return __awaiter(this, void 0, void 0, function () {
30504
+ var json, now;
30505
+ var _this = this;
30506
+ return __generator(this, function (_b) {
30507
+ switch (_b.label) {
30508
+ case 0:
30509
+ if (isEmptyArray(entities))
30510
+ return [2 /*return*/, entities];
30511
+ if (!this.mutations.saveAll) {
30512
+ if (!this.mutations.save)
30513
+ throw new Error('Not implemented');
30514
+ // Save one by one
30515
+ return [2 /*return*/, chainPromises(entities.map(function (entity) { return function () { return _this.save(entity, opts); }; }))];
30516
+ }
30517
+ json = entities.map(function (entity) {
30518
+ _this.fillDefaultProperties(entity);
30519
+ return entity.asObject();
30520
+ });
30521
+ now = Date.now();
30522
+ if (this._debug)
30523
+ console.debug(this._logPrefix + "Saving user events...", json);
30524
+ return [4 /*yield*/, this.graphql.mutate({
30525
+ mutation: this.mutations.saveAll,
30526
+ variables: {
30527
+ data: json
30528
+ },
30529
+ error: { code: SocialErrorCodes.SAVE_USER_EVENT_ERROR, message: 'SOCIAL.ERROR.SAVE_USER_EVENT_ERROR' },
30530
+ update: function (proxy, _b) {
30531
+ var data = _b.data;
30532
+ // Update entity
30533
+ var savedEntities = (data === null || data === void 0 ? void 0 : data.data) || [];
30534
+ if (savedEntities.length) {
30535
+ if (_this._debug)
30536
+ console.debug(_this._logPrefix + "User events saved in " + (Date.now() - now) + "ms", savedEntities);
30537
+ entities.forEach(function (entity) {
30538
+ var savedEntity = savedEntities.find(function (e) { return EntityUtils.equals(e, entity, 'id'); });
30539
+ _this.copyIdAndUpdateDate(savedEntity, entity);
30540
+ });
30541
+ // Add to cache (assuming all with content)
30542
+ _this.insertIntoMutableCachedQueries(proxy, {
30543
+ query: _this.queries.loadAllWithContent,
30544
+ data: savedEntities
30545
+ });
30546
+ }
30547
+ }
30548
+ })];
30549
+ case 1:
30550
+ _b.sent();
30551
+ return [2 /*return*/, entities];
30552
+ }
30553
+ });
30554
+ });
30456
30555
  };
30457
- AbstractUserEventService.prototype.markAsRead = function (entity) {
30556
+ AbstractUserEventService.prototype.markAsRead = function (entities) {
30458
30557
  return __awaiter(this, void 0, void 0, function () {
30459
- var onReadListeners, onReadListeners_1, onReadListeners_1_1, listener, e_1_1;
30460
- var e_1, _b;
30461
- return __generator(this, function (_c) {
30462
- switch (_c.label) {
30558
+ var userEventWithoutReadListeners, _loop_1, this_1, _b, _c, entity, e_1_1;
30559
+ var e_1, _d;
30560
+ return __generator(this, function (_e) {
30561
+ switch (_e.label) {
30463
30562
  case 0:
30464
- onReadListeners = (this.listeners || []).filter(function (listener) { return !!listener.onRead; }).filter(function (listener) { return listener.accept(entity); });
30465
- if (!onReadListeners.length) return [3 /*break*/, 9];
30466
- _c.label = 1;
30563
+ userEventWithoutReadListeners = [];
30564
+ _loop_1 = function (entity) {
30565
+ var onReadListeners, onReadListeners_1, onReadListeners_1_1, listener, e_2_1;
30566
+ var e_2, _b;
30567
+ return __generator(this, function (_c) {
30568
+ switch (_c.label) {
30569
+ case 0:
30570
+ onReadListeners = (this_1.listeners || []).filter(function (listener) { return !!listener.onRead; }).filter(function (listener) { return listener.accept(entity); });
30571
+ if (!onReadListeners.length) return [3 /*break*/, 9];
30572
+ _c.label = 1;
30573
+ case 1:
30574
+ _c.trys.push([1, 6, 7, 8]);
30575
+ onReadListeners_1 = (e_2 = void 0, __values(onReadListeners)), onReadListeners_1_1 = onReadListeners_1.next();
30576
+ _c.label = 2;
30577
+ case 2:
30578
+ if (!!onReadListeners_1_1.done) return [3 /*break*/, 5];
30579
+ listener = onReadListeners_1_1.value;
30580
+ return [4 /*yield*/, listener.onRead(entity)];
30581
+ case 3:
30582
+ _c.sent();
30583
+ _c.label = 4;
30584
+ case 4:
30585
+ onReadListeners_1_1 = onReadListeners_1.next();
30586
+ return [3 /*break*/, 2];
30587
+ case 5: return [3 /*break*/, 8];
30588
+ case 6:
30589
+ e_2_1 = _c.sent();
30590
+ e_2 = { error: e_2_1 };
30591
+ return [3 /*break*/, 8];
30592
+ case 7:
30593
+ try {
30594
+ if (onReadListeners_1_1 && !onReadListeners_1_1.done && (_b = onReadListeners_1.return)) _b.call(onReadListeners_1);
30595
+ }
30596
+ finally { if (e_2) throw e_2.error; }
30597
+ return [7 /*endfinally*/];
30598
+ case 8: return [3 /*break*/, 10];
30599
+ case 9:
30600
+ // Add to this list for default operation
30601
+ userEventWithoutReadListeners.push(entity);
30602
+ _c.label = 10;
30603
+ case 10: return [2 /*return*/];
30604
+ }
30605
+ });
30606
+ };
30607
+ this_1 = this;
30608
+ _e.label = 1;
30467
30609
  case 1:
30468
- _c.trys.push([1, 6, 7, 8]);
30469
- onReadListeners_1 = __values(onReadListeners), onReadListeners_1_1 = onReadListeners_1.next();
30470
- _c.label = 2;
30610
+ _e.trys.push([1, 6, 7, 8]);
30611
+ _b = __values((entities || [])), _c = _b.next();
30612
+ _e.label = 2;
30471
30613
  case 2:
30472
- if (!!onReadListeners_1_1.done) return [3 /*break*/, 5];
30473
- listener = onReadListeners_1_1.value;
30474
- return [4 /*yield*/, listener.onRead(entity)];
30614
+ if (!!_c.done) return [3 /*break*/, 5];
30615
+ entity = _c.value;
30616
+ return [5 /*yield**/, _loop_1(entity)];
30475
30617
  case 3:
30476
- _c.sent();
30477
- _c.label = 4;
30618
+ _e.sent();
30619
+ _e.label = 4;
30478
30620
  case 4:
30479
- onReadListeners_1_1 = onReadListeners_1.next();
30621
+ _c = _b.next();
30480
30622
  return [3 /*break*/, 2];
30481
30623
  case 5: return [3 /*break*/, 8];
30482
30624
  case 6:
30483
- e_1_1 = _c.sent();
30625
+ e_1_1 = _e.sent();
30484
30626
  e_1 = { error: e_1_1 };
30485
30627
  return [3 /*break*/, 8];
30486
30628
  case 7:
30487
30629
  try {
30488
- if (onReadListeners_1_1 && !onReadListeners_1_1.done && (_b = onReadListeners_1.return)) _b.call(onReadListeners_1);
30630
+ if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
30489
30631
  }
30490
30632
  finally { if (e_1) throw e_1.error; }
30491
30633
  return [7 /*endfinally*/];
30492
- case 8: return [3 /*break*/, 11];
30493
- case 9:
30634
+ case 8:
30494
30635
  // Use default
30495
- return [4 /*yield*/, this.defaultMarkAsRead(entity)];
30496
- case 10:
30636
+ return [4 /*yield*/, this.defaultMarkAsRead(userEventWithoutReadListeners)];
30637
+ case 9:
30497
30638
  // Use default
30498
- _c.sent();
30499
- _c.label = 11;
30500
- case 11: return [2 /*return*/];
30639
+ _e.sent();
30640
+ return [2 /*return*/];
30501
30641
  }
30502
30642
  });
30503
30643
  });
@@ -30507,13 +30647,40 @@
30507
30647
  this.listeners = [];
30508
30648
  this.listeners.push(listener);
30509
30649
  };
30650
+ AbstractUserEventService.prototype.resetCount = function () {
30651
+ this._count$.next(undefined);
30652
+ };
30510
30653
  /* -- protected methods -- */
30511
- AbstractUserEventService.prototype.processUserEvent = function (source) {
30512
- var e_2, _b;
30654
+ AbstractUserEventService.prototype.onLogin = function () {
30655
+ return __awaiter(this, void 0, void 0, function () {
30656
+ var count;
30657
+ return __generator(this, function (_b) {
30658
+ switch (_b.label) {
30659
+ case 0: return [4 /*yield*/, this.count(undefined)];
30660
+ case 1:
30661
+ count = _b.sent();
30662
+ if (this._debug)
30663
+ console.debug(this._logPrefix + "Receiving user events count", count);
30664
+ // Update count
30665
+ this._count$.next(count);
30666
+ // Then listen changes
30667
+ this._listenSubscription = this.listenCountChanges(undefined).subscribe();
30668
+ return [2 /*return*/];
30669
+ }
30670
+ });
30671
+ });
30672
+ };
30673
+ AbstractUserEventService.prototype.onLogout = function () {
30674
+ var _a;
30675
+ (_a = this._listenSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
30676
+ };
30677
+ AbstractUserEventService.prototype.processUserEvent = function (source, that) {
30678
+ var e_3, _b;
30679
+ that = that || this;
30513
30680
  // Convert json source to IUserEvent
30514
- var target = this.fromObject(source);
30681
+ var target = that.fromObject(source);
30515
30682
  // Get listeners
30516
- var listeners = (this.listeners || []).filter(function (listener) { return listener.onReceived; }).filter(function (listener) { return listener.accept(target); });
30683
+ var listeners = (that.listeners || []).filter(function (listener) { return listener.onReceived; }).filter(function (listener) { return listener.accept(target); });
30517
30684
  try {
30518
30685
  for (var listeners_1 = __values(listeners), listeners_1_1 = listeners_1.next(); !listeners_1_1.done; listeners_1_1 = listeners_1.next()) {
30519
30686
  var listener = listeners_1_1.value;
@@ -30521,39 +30688,47 @@
30521
30688
  target = listener.onReceived(target);
30522
30689
  }
30523
30690
  else {
30524
- if (this._debug)
30525
- console.debug(this._logPrefix + "Event has been rejected by a listener", source);
30691
+ if (that._debug)
30692
+ console.debug(that._logPrefix + "Event has been rejected by a listener", source);
30526
30693
  break;
30527
30694
  }
30528
30695
  }
30529
30696
  }
30530
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
30697
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
30531
30698
  finally {
30532
30699
  try {
30533
30700
  if (listeners_1_1 && !listeners_1_1.done && (_b = listeners_1.return)) _b.call(listeners_1);
30534
30701
  }
30535
- finally { if (e_2) throw e_2.error; }
30702
+ finally { if (e_3) throw e_3.error; }
30536
30703
  }
30537
30704
  return target;
30538
30705
  };
30539
- AbstractUserEventService.prototype.defaultMarkAsRead = function (userEvent) {
30706
+ AbstractUserEventService.prototype.defaultMarkAsRead = function (userEvents) {
30540
30707
  return __awaiter(this, void 0, void 0, function () {
30708
+ var localEntities, remoteEntities;
30541
30709
  return __generator(this, function (_b) {
30542
30710
  switch (_b.label) {
30543
30711
  case 0:
30544
- if (!userEvent)
30712
+ if (!userEvents)
30545
30713
  throw new Error(this._logPrefix + "Invalid event to save");
30714
+ if (!userEvents.length)
30715
+ return [2 /*return*/];
30546
30716
  // set read date
30547
- userEvent.readDate = moment$6();
30548
- if (!(!userEvent.id || userEvent.id < 0)) return [3 /*break*/, 1];
30549
- if (this._debug)
30550
- console.debug(this._logPrefix + "Save local user event");
30551
- return [3 /*break*/, 3];
30552
- case 1: return [4 /*yield*/, this.save(userEvent)];
30553
- case 2:
30717
+ userEvents.forEach(function (userEvent) { return userEvent.readDate = moment$6(); });
30718
+ localEntities = userEvents.filter(function (userEvent) { return !userEvent.id || userEvent.id < 0; });
30719
+ remoteEntities = userEvents.filter(function (userEvent) { return userEvent.id > 0; });
30720
+ // save local entities
30721
+ if (localEntities.length) {
30722
+ if (this._debug)
30723
+ console.debug(this._logPrefix + "Save local user event");
30724
+ // TODO !!!!!!!!!!!!!
30725
+ }
30726
+ if (!remoteEntities.length) return [3 /*break*/, 2];
30727
+ return [4 /*yield*/, this.saveAll(remoteEntities)];
30728
+ case 1:
30554
30729
  _b.sent();
30555
- _b.label = 3;
30556
- case 3: return [2 /*return*/];
30730
+ _b.label = 2;
30731
+ case 2: return [2 /*return*/];
30557
30732
  }
30558
30733
  });
30559
30734
  });
@@ -30592,7 +30767,6 @@
30592
30767
  { type: AccountService },
30593
30768
  { type: NetworkService },
30594
30769
  { type: i1$2.TranslateService },
30595
- { type: i1$5.ToastController },
30596
30770
  { type: undefined },
30597
30771
  { type: undefined },
30598
30772
  { type: undefined },
@@ -30609,7 +30783,7 @@
30609
30783
  var UserEventService = /** @class */ (function (_super) {
30610
30784
  __extends(UserEventService, _super);
30611
30785
  function UserEventService(graphql, accountService, network, translate, toastController, environment) {
30612
- var _this = _super.call(this, graphql, accountService, network, translate, toastController, userEventQueries, userEventMutations, undefined, environment) || this;
30786
+ var _this = _super.call(this, graphql, accountService, network, translate, userEventQueries, userEventMutations, undefined, environment) || this;
30613
30787
  _this.graphql = graphql;
30614
30788
  _this.accountService = accountService;
30615
30789
  _this.network = network;
@@ -30932,17 +31106,48 @@
30932
31106
  };
30933
31107
 
30934
31108
  var UserEventNotificationList = /** @class */ (function () {
30935
- function UserEventNotificationList(popoverController) {
31109
+ function UserEventNotificationList(cd, popoverController, userEventService) {
31110
+ this.cd = cd;
30936
31111
  this.popoverController = popoverController;
31112
+ this.userEventService = userEventService;
31113
+ this.debug = false;
31114
+ this.userEvents = new rxjs.BehaviorSubject(undefined);
31115
+ this.subscriptions = new rxjs.Subscription();
30937
31116
  }
30938
31117
  UserEventNotificationList.prototype.ngOnInit = function () {
31118
+ var _this = this;
31119
+ // Watch all user events
31120
+ this.subscriptions.add(this.userEventService
31121
+ .watchAll(0, 10, 'creationDate', "desc", undefined)
31122
+ .subscribe(function (result) {
31123
+ if (_this.debug)
31124
+ console.debug("[user-event-notification-list] receiving " + result.total + " user events", result.data);
31125
+ _this.userEvents.next(result.data);
31126
+ _this.markForCheck();
31127
+ }));
31128
+ // Listen changes
31129
+ this.subscriptions.add(this.userEventService.listenChanges(undefined)
31130
+ .subscribe(function (data) {
31131
+ if (_this.debug)
31132
+ console.debug("[user-event-notification-list] receiving " + data.length + " new user events", data);
31133
+ }));
30939
31134
  };
30940
- UserEventNotificationList.prototype.read = function ($event, userEvent) {
31135
+ UserEventNotificationList.prototype.ngOnDestroy = function () {
31136
+ this.subscriptions.unsubscribe();
31137
+ };
31138
+ UserEventNotificationList.prototype.read = function (event, userEvent) {
30941
31139
  var _a;
30942
31140
  if (userEvent === null || userEvent === void 0 ? void 0 : userEvent.readDate)
30943
31141
  return;
30944
31142
  (_a = this.readEvent) === null || _a === void 0 ? void 0 : _a.emit(userEvent);
30945
31143
  };
31144
+ UserEventNotificationList.prototype.readAll = function (event) {
31145
+ var _a;
31146
+ var unreadUserEvents = (this.userEvents.value || []).filter(function (value) { return !value.readDate; });
31147
+ if (!unreadUserEvents.length)
31148
+ return;
31149
+ (_a = this.readEvents) === null || _a === void 0 ? void 0 : _a.emit(unreadUserEvents);
31150
+ };
30946
31151
  UserEventNotificationList.prototype.executeAction = function (action, userEvent) {
30947
31152
  // Execute then close popover
30948
31153
  action.executeAction(userEvent);
@@ -30951,37 +31156,42 @@
30951
31156
  UserEventNotificationList.prototype.dismiss = function () {
30952
31157
  this.popoverController.dismiss();
30953
31158
  };
31159
+ UserEventNotificationList.prototype.markForCheck = function () {
31160
+ this.cd.markForCheck();
31161
+ };
30954
31162
  return UserEventNotificationList;
30955
31163
  }());
30956
31164
  UserEventNotificationList.decorators = [
30957
31165
  { type: i0.Component, args: [{
30958
31166
  selector: 'app-user-event-notification-list',
30959
- template: "\n<ion-list class=\"ion-list-popover\">\n\n <ion-row class=\"ion-list-header column\">\n <ion-col>\n <ion-label>{{titleI18n | translate}}</ion-label>\n </ion-col>\n </ion-row>\n\n <ion-item *ngIf=\"!(userEvents | async)?.length\">\n {{'SOCIAL.USER_EVENT.NOTIFICATION.EMPTY' | translate}}\n </ion-item>\n <ion-item\n *ngFor=\"let userEvent of userEvents | async\"\n (click)=\"read($event, userEvent)\"\n >\n\n <ion-avatar slot=\"start\">\n\n <img *ngIf=\"userEvent.avatar; else avatarIcon\" src=\"{{ userEvent.avatar }}\">\n\n <ng-template #avatarIcon>\n <app-icon\n *ngIf=\"userEvent.avatarIcon\"\n [ref]=\"userEvent.avatarIcon\"\n height=\"40\"\n width=\"40\"\n ></app-icon>\n </ng-template>\n\n </ion-avatar>\n\n <ion-grid class=\"ion-no-margin ion-no-padding\">\n <ion-row>\n <ion-col>\n <p [class.unread]=\"!userEvent.readDate\">\n {{userEvent.message}}\n </p>\n </ion-col>\n </ion-row>\n <ion-row *ngIf=\"userEvent.actions?.length\">\n <ion-col>\n <p>\n <span *ngFor=\"let action of userEvent.actions\">\n <a\n [style.margin-right.px]=\"8\"\n [style.cursor]=\"'pointer'\"\n (click)=\"executeAction(action, userEvent)\"\n >\n {{ '&#10142;&nbsp;' + action.name}}\n </a>\n </span>\n </p>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col>\n <app-icon\n *ngIf=\"userEvent.icon\"\n [ref]=\"userEvent.icon\"\n height=\"16\"\n width=\"16\"\n [style.vertical-align]=\"'sub'\"\n ></app-icon>\n <small>\n <span>{{userEvent.creationDate|dateFromNow}}</span>\n <span [style.color]=\"'gray'\">{{ ' | ' + (userEvent.creationDate|dateFormat:{time:true}) }}</span>\n </small>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-item>\n\n</ion-list>\n",
31167
+ template: "\n<ion-list class=\"ion-list-popover\">\n\n <ion-row class=\"ion-list-header column\">\n <ion-col>\n <ion-label>{{titleI18n | translate}}</ion-label>\n </ion-col>\n </ion-row>\n\n <ion-item *ngIf=\"!(userEvents | async)?.length\">\n {{'SOCIAL.USER_EVENT.NOTIFICATION.EMPTY' | translate}}\n </ion-item>\n <ion-item\n *ngFor=\"let userEvent of userEvents | async\"\n (click)=\"read($event, userEvent)\"\n >\n\n <ion-avatar slot=\"start\">\n\n <img *ngIf=\"userEvent.avatar; else avatarIcon\" src=\"{{ userEvent.avatar }}\">\n\n <ng-template #avatarIcon>\n <app-icon\n *ngIf=\"userEvent.avatarIcon\"\n [ref]=\"userEvent.avatarIcon\"\n height=\"40\"\n width=\"40\"\n ></app-icon>\n </ng-template>\n\n </ion-avatar>\n\n <ion-grid class=\"ion-no-margin ion-no-padding\">\n <ion-row>\n <ion-col>\n <p [class.unread]=\"!userEvent.readDate\">\n {{userEvent.message}}\n </p>\n </ion-col>\n </ion-row>\n <ion-row *ngIf=\"userEvent.actions?.length\">\n <ion-col>\n <p>\n <span *ngFor=\"let action of userEvent.actions\">\n <a\n [style.margin-right.px]=\"8\"\n [style.cursor]=\"'pointer'\"\n (click)=\"executeAction(action, userEvent)\"\n >\n {{ '&#10142;&nbsp;' + action.name}}\n </a>\n </span>\n </p>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col>\n <app-icon\n *ngIf=\"userEvent.icon\"\n [ref]=\"userEvent.icon\"\n height=\"16\"\n width=\"16\"\n [style.vertical-align]=\"'sub'\"\n ></app-icon>\n <small>\n <span>{{userEvent.creationDate|dateFromNow}}</span>\n <span [style.color]=\"'gray'\">{{ ' | ' + (userEvent.creationDate|dateFormat:{time:true}) }}</span>\n </small>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-item>\n\n <ion-row class=\"ion-list-footer column\">\n <ion-col>\n <a style=\"cursor: pointer\" (click)=\"readAll($event)\">{{'SOCIAL.USER_EVENT.NOTIFICATION.READ_ALL' | translate}}</a>\n </ion-col>\n </ion-row>\n\n</ion-list>\n",
31168
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
30960
31169
  styles: [":host(.popover-viewport){overflow-y:auto;-webkit-user-select:none;-moz-user-select:none;user-select:none}.unread{font-weight:700}"]
30961
31170
  },] }
30962
31171
  ];
30963
31172
  UserEventNotificationList.ctorParameters = function () { return [
30964
- { type: i1$5.PopoverController }
31173
+ { type: i0.ChangeDetectorRef },
31174
+ { type: i1$5.PopoverController },
31175
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [UserEventServiceToken,] }] }
30965
31176
  ]; };
30966
31177
  UserEventNotificationList.propDecorators = {
31178
+ debug: [{ type: i0.Input }],
30967
31179
  titleI18n: [{ type: i0.Input }],
30968
- userEvents: [{ type: i0.Input }],
30969
- readEvent: [{ type: i0.Output }]
31180
+ readEvent: [{ type: i0.Output }],
31181
+ readEvents: [{ type: i0.Output }]
30970
31182
  };
30971
31183
 
30972
31184
  var UserEventNotificationComponent = /** @class */ (function () {
30973
- function UserEventNotificationComponent(userEventService, accountService, popoverController, cd) {
31185
+ function UserEventNotificationComponent(userEventService, accountService, popoverController) {
30974
31186
  this.userEventService = userEventService;
30975
31187
  this.accountService = accountService;
30976
31188
  this.popoverController = popoverController;
30977
- this.cd = cd;
30978
31189
  this.debug = false;
30979
31190
  this.titleI18n = 'SOCIAL.USER_EVENT.NOTIFICATION.TITLE';
30980
31191
  this.disabled = false;
30981
- this.userEventsSubject = new rxjs.BehaviorSubject(undefined);
30982
- this._subscriptions = new rxjs.Subscription();
30983
31192
  this._logPrefix = '[user-event-notification] ';
30984
31193
  this._readEvent = new i0.EventEmitter();
31194
+ this._readEvents = new i0.EventEmitter();
30985
31195
  }
30986
31196
  Object.defineProperty(UserEventNotificationComponent.prototype, "count", {
30987
31197
  get: function () {
@@ -30992,24 +31202,24 @@
30992
31202
  configurable: true
30993
31203
  });
30994
31204
  UserEventNotificationComponent.prototype.ngOnInit = function () {
30995
- var _this = this;
30996
- var _a;
30997
- if (isNil(this.userEventService)) {
30998
- console.warn(this._logPrefix + "No service injected");
30999
- this.disabled = true;
31000
- return;
31001
- }
31002
- this._subscriptions.add(this.userEventService.watchAll(0, 10, 'creationDate', "desc", {
31003
- recipients: [(_a = this.accountService.person) === null || _a === void 0 ? void 0 : _a.pubkey]
31004
- }).subscribe(function (value) {
31005
- var data = value.data;
31006
- if (_this.debug) {
31007
- console.debug(_this._logPrefix + "Receiving user events", data);
31008
- }
31009
- _this.userEventsSubject.next(data);
31010
- }));
31011
- this._readEvent.subscribe(function (value) {
31012
- _this.userEventService.markAsRead(value);
31205
+ return __awaiter(this, void 0, void 0, function () {
31206
+ var _this = this;
31207
+ return __generator(this, function (_b) {
31208
+ if (isNil(this.userEventService)) {
31209
+ console.warn(this._logPrefix + "No service injected");
31210
+ this.disabled = true;
31211
+ return [2 /*return*/];
31212
+ }
31213
+ // Subscribe to read event
31214
+ this._readEvent.subscribe(function (value) {
31215
+ // default: mark event as read
31216
+ _this.userEventService.markAsRead([value]);
31217
+ });
31218
+ this._readEvents.subscribe(function (value) {
31219
+ _this.userEventService.markAsRead(value);
31220
+ });
31221
+ return [2 /*return*/];
31222
+ });
31013
31223
  });
31014
31224
  };
31015
31225
  UserEventNotificationComponent.prototype.showList = function (event) {
@@ -31017,19 +31227,23 @@
31017
31227
  var popover;
31018
31228
  return __generator(this, function (_b) {
31019
31229
  switch (_b.label) {
31020
- case 0: return [4 /*yield*/, this.popoverController.create({
31021
- component: UserEventNotificationList,
31022
- componentProps: {
31023
- titleI18n: this.titleI18n,
31024
- userEvents: this.userEventsSubject,
31025
- readEvent: this._readEvent
31026
- },
31027
- backdropDismiss: true,
31028
- keyboardClose: true,
31029
- event: event,
31030
- translucent: true,
31031
- cssClass: 'popover-large'
31032
- })];
31230
+ case 0:
31231
+ // Reset count
31232
+ this.userEventService.resetCount();
31233
+ return [4 /*yield*/, this.popoverController.create({
31234
+ component: UserEventNotificationList,
31235
+ componentProps: {
31236
+ debug: this.debug,
31237
+ titleI18n: this.titleI18n,
31238
+ readEvent: this._readEvent,
31239
+ readEvents: this._readEvents
31240
+ },
31241
+ backdropDismiss: true,
31242
+ keyboardClose: true,
31243
+ event: event,
31244
+ translucent: true,
31245
+ cssClass: 'popover-large'
31246
+ })];
31033
31247
  case 1:
31034
31248
  popover = _b.sent();
31035
31249
  return [4 /*yield*/, popover.present()];
@@ -31040,14 +31254,10 @@
31040
31254
  });
31041
31255
  });
31042
31256
  };
31043
- UserEventNotificationComponent.prototype.markForCheck = function () {
31044
- this.cd.markForCheck();
31045
- };
31046
31257
  UserEventNotificationComponent.prototype.ngOnDestroy = function () {
31047
31258
  if (this.debug) {
31048
31259
  console.debug(this._logPrefix + "Destroying");
31049
31260
  }
31050
- this._subscriptions.unsubscribe();
31051
31261
  };
31052
31262
  return UserEventNotificationComponent;
31053
31263
  }());
@@ -31062,8 +31272,7 @@
31062
31272
  UserEventNotificationComponent.ctorParameters = function () { return [
31063
31273
  { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [UserEventServiceToken,] }] },
31064
31274
  { type: AccountService },
31065
- { type: i1$5.PopoverController },
31066
- { type: i0.ChangeDetectorRef }
31275
+ { type: i1$5.PopoverController }
31067
31276
  ]; };
31068
31277
  UserEventNotificationComponent.propDecorators = {
31069
31278
  debug: [{ type: i0.Input }],
@@ -31071,6 +31280,100 @@
31071
31280
  disabled: [{ type: i0.Input }]
31072
31281
  };
31073
31282
 
31283
+ var UserEventTestService = /** @class */ (function (_super) {
31284
+ __extends(UserEventTestService, _super);
31285
+ function UserEventTestService(graphql, accountService, network, translate, environment) {
31286
+ var _this = _super.call(this, graphql, accountService, network, translate, undefined, undefined, undefined, environment) || this;
31287
+ _this.graphql = graphql;
31288
+ _this.accountService = accountService;
31289
+ _this.network = network;
31290
+ _this.translate = translate;
31291
+ _this.environment = environment;
31292
+ _this.userEvents = [];
31293
+ return _this;
31294
+ }
31295
+ UserEventTestService.prototype.fromObject = function (source) {
31296
+ return exports.UserEvent.fromObject(source);
31297
+ };
31298
+ UserEventTestService.prototype.add = function (entity) {
31299
+ entity = this.processUserEvent(entity);
31300
+ entity.id = this.userEvents.length + 1;
31301
+ this.userEvents.push(entity);
31302
+ this._count$.next(this.userEvents.length);
31303
+ };
31304
+ UserEventTestService.prototype.asFilter = function (filter) {
31305
+ return filter;
31306
+ };
31307
+ UserEventTestService.prototype.count = function (filter, options) {
31308
+ return Promise.resolve(this.userEvents.length);
31309
+ };
31310
+ UserEventTestService.prototype.delete = function (entity) {
31311
+ return Promise.resolve(undefined);
31312
+ };
31313
+ UserEventTestService.prototype.deleteAll = function (data, opts) {
31314
+ return Promise.resolve(undefined);
31315
+ };
31316
+ UserEventTestService.prototype.listenChanges = function (filter, options) {
31317
+ return rxjs.of();
31318
+ };
31319
+ UserEventTestService.prototype.save = function (entity, options) {
31320
+ var _a;
31321
+ var toSave = (_a = this.userEvents) === null || _a === void 0 ? void 0 : _a.find(function (value) { return value.id == (entity === null || entity === void 0 ? void 0 : entity.id); });
31322
+ Object.assign(toSave, entity);
31323
+ return entity;
31324
+ };
31325
+ UserEventTestService.prototype.saveAll = function (data, opts) {
31326
+ return __awaiter(this, void 0, void 0, function () {
31327
+ var _b, _c, entity, e_1_1;
31328
+ var e_1, _d;
31329
+ return __generator(this, function (_e) {
31330
+ switch (_e.label) {
31331
+ case 0:
31332
+ _e.trys.push([0, 5, 6, 7]);
31333
+ _b = __values((data || [])), _c = _b.next();
31334
+ _e.label = 1;
31335
+ case 1:
31336
+ if (!!_c.done) return [3 /*break*/, 4];
31337
+ entity = _c.value;
31338
+ return [4 /*yield*/, this.save(entity)];
31339
+ case 2:
31340
+ _e.sent();
31341
+ _e.label = 3;
31342
+ case 3:
31343
+ _c = _b.next();
31344
+ return [3 /*break*/, 1];
31345
+ case 4: return [3 /*break*/, 7];
31346
+ case 5:
31347
+ e_1_1 = _e.sent();
31348
+ e_1 = { error: e_1_1 };
31349
+ return [3 /*break*/, 7];
31350
+ case 6:
31351
+ try {
31352
+ if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
31353
+ }
31354
+ finally { if (e_1) throw e_1.error; }
31355
+ return [7 /*endfinally*/];
31356
+ case 7: return [2 /*return*/, Promise.resolve(this.userEvents)];
31357
+ }
31358
+ });
31359
+ });
31360
+ };
31361
+ UserEventTestService.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter, options) {
31362
+ return rxjs.of({ data: this.userEvents });
31363
+ };
31364
+ return UserEventTestService;
31365
+ }(AbstractUserEventService));
31366
+ UserEventTestService.decorators = [
31367
+ { type: i0.Injectable }
31368
+ ];
31369
+ UserEventTestService.ctorParameters = function () { return [
31370
+ { type: GraphqlService },
31371
+ { type: AccountService },
31372
+ { type: NetworkService },
31373
+ { type: i1$2.TranslateService },
31374
+ { type: Environment, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [ENVIRONMENT,] }] }
31375
+ ]; };
31376
+
31074
31377
  var UserEventModule = /** @class */ (function () {
31075
31378
  function UserEventModule() {
31076
31379
  }
@@ -31091,6 +31394,9 @@
31091
31394
  exports: [
31092
31395
  UserEventsTable,
31093
31396
  UserEventNotificationComponent
31397
+ ],
31398
+ providers: [
31399
+ { provide: UserEventServiceToken, useClass: UserEventTestService }
31094
31400
  ]
31095
31401
  },] }
31096
31402
  ];
@@ -31376,7 +31682,7 @@
31376
31682
  ], exports.JobProgression);
31377
31683
 
31378
31684
  var JobProgressionServiceToken = new i0.InjectionToken('JobProgressionService');
31379
- var jobProgressionSubscription = core.gql(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["subscription UpdateJobProgression($id: Int!, $interval: Int){\n data: updateJobProgression(id: $id, interval: $interval) {\n id\n message\n current\n total\n updateDate\n }\n}"], ["subscription UpdateJobProgression($id: Int!, $interval: Int){\n data: updateJobProgression(id: $id, interval: $interval) {\n id\n message\n current\n total\n updateDate\n }\n}"])));
31685
+ var jobProgressionSubscription = core.gql(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["subscription UpdateJobProgression($id: Int!, $interval: Int){\n data: updateJobProgression(id: $id, interval: $interval) {\n id\n message\n current\n total\n }\n}"], ["subscription UpdateJobProgression($id: Int!, $interval: Int){\n data: updateJobProgression(id: $id, interval: $interval) {\n id\n message\n current\n total\n }\n}"])));
31380
31686
  var JobProgressionService = /** @class */ (function (_super) {
31381
31687
  __extends(JobProgressionService, _super);
31382
31688
  function JobProgressionService(graphql, environment) {
@@ -34253,12 +34559,13 @@
34253
34559
  exports.ɵi = AppUpdateOfflineModeCard;
34254
34560
  exports.ɵj = AppIconComponent;
34255
34561
  exports.ɵk = UserEventNotificationList;
34256
- exports.ɵl = JobProgressionList;
34257
- exports.ɵm = DateTestPage;
34258
- exports.ɵn = NumpadTestPage;
34259
- exports.ɵo = MatBadgeIconTestPage;
34260
- exports.ɵp = ToastTestingModule;
34261
- exports.ɵq = ToastTestingPage;
34562
+ exports.ɵl = UserEventTestService;
34563
+ exports.ɵm = JobProgressionList;
34564
+ exports.ɵn = DateTestPage;
34565
+ exports.ɵo = NumpadTestPage;
34566
+ exports.ɵp = MatBadgeIconTestPage;
34567
+ exports.ɵq = ToastTestingModule;
34568
+ exports.ɵr = ToastTestingPage;
34262
34569
 
34263
34570
  Object.defineProperty(exports, '__esModule', { value: true });
34264
34571