@banta/sdk 4.0.12 → 4.0.13

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators'), require('@angular/core'), require('@angular/common'), require('@angular/material/icon'), require('@angular/platform-browser'), require('@angular/material/button'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/forms'), require('@angular/material/dialog'), require('@banta/common'), require('@angular/router'), require('@angular/material/menu'), require('@angular/material/progress-spinner'), require('@angular/cdk/text-field'), require('@angular/material/tooltip'), require('@angular/material/select')) :
3
- typeof define === 'function' && define.amd ? define('@banta/sdk', ['exports', 'rxjs', 'rxjs/operators', '@angular/core', '@angular/common', '@angular/material/icon', '@angular/platform-browser', '@angular/material/button', '@angular/material/form-field', '@angular/material/input', '@angular/forms', '@angular/material/dialog', '@banta/common', '@angular/router', '@angular/material/menu', '@angular/material/progress-spinner', '@angular/cdk/text-field', '@angular/material/tooltip', '@angular/material/select'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.banta = global.banta || {}, global.banta.sdk = {}), global.rxjs, global.rxjs.operators, global.ng.core, global.ng.common, global.ng.material.icon, global.ng.platformBrowser, global.ng.material.button, global.ng.material.formField, global.ng.material.input, global.ng.forms, global.ng.material.dialog, global.common$1, global.ng.router, global.ng.material.menu, global.ng.material.progressSpinner, global.ng.cdk.textField, global.ng.material.tooltip, global.ng.material.select));
5
- }(this, (function (exports, rxjs, operators, core, common, icon, platformBrowser, button, formField, input, forms, dialog, common$1, router, menu, progressSpinner, textField, tooltip, select) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators'), require('@angular/core'), require('@angular/common'), require('@angular/material/icon'), require('@angular/platform-browser'), require('@angular/material/button'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/forms'), require('@angular/material/dialog'), require('@banta/common'), require('@angular/router'), require('@angular/material/snack-bar'), require('@angular/material/menu'), require('@angular/material/progress-spinner'), require('@angular/cdk/text-field'), require('@angular/material/tooltip'), require('@angular/material/select')) :
3
+ typeof define === 'function' && define.amd ? define('@banta/sdk', ['exports', 'rxjs', 'rxjs/operators', '@angular/core', '@angular/common', '@angular/material/icon', '@angular/platform-browser', '@angular/material/button', '@angular/material/form-field', '@angular/material/input', '@angular/forms', '@angular/material/dialog', '@banta/common', '@angular/router', '@angular/material/snack-bar', '@angular/material/menu', '@angular/material/progress-spinner', '@angular/cdk/text-field', '@angular/material/tooltip', '@angular/material/select'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.banta = global.banta || {}, global.banta.sdk = {}), global.rxjs, global.rxjs.operators, global.ng.core, global.ng.common, global.ng.material.icon, global.ng.platformBrowser, global.ng.material.button, global.ng.material.formField, global.ng.material.input, global.ng.forms, global.ng.material.dialog, global.common$1, global.ng.router, global.ng.material.snackBar, global.ng.material.menu, global.ng.material.progressSpinner, global.ng.cdk.textField, global.ng.material.tooltip, global.ng.material.select));
5
+ }(this, (function (exports, rxjs, operators, core, common, icon, platformBrowser, button, formField, input, forms, dialog, common$1, router, snackBar, menu, progressSpinner, textField, tooltip, select) { 'use strict';
6
6
 
7
7
  function lazyConnection(options) {
8
8
  var obs = new rxjs.Observable(function (observer) {
@@ -8294,7 +8294,6 @@
8294
8294
  };
8295
8295
  CommentComponent.prototype.avatarForUser = function (user) {
8296
8296
  var url = this.genericAvatarUrl;
8297
- console.log("GENERIC: " + this.genericAvatarUrl);
8298
8297
  if (user && user.avatarUrl) {
8299
8298
  url = user.avatarUrl;
8300
8299
  }
@@ -8650,11 +8649,12 @@
8650
8649
  * Comments component
8651
8650
  */
8652
8651
  var BantaCommentsComponent = /** @class */ (function () {
8653
- function BantaCommentsComponent(backend, elementRef, activatedRoute) {
8652
+ function BantaCommentsComponent(backend, elementRef, activatedRoute, matSnackBar) {
8654
8653
  var _this = this;
8655
8654
  this.backend = backend;
8656
8655
  this.elementRef = elementRef;
8657
8656
  this.activatedRoute = activatedRoute;
8657
+ this.matSnackBar = matSnackBar;
8658
8658
  // Loading Screen
8659
8659
  this._loadingMessage = '';
8660
8660
  this.loadingMessageVisible = false;
@@ -8680,6 +8680,12 @@
8680
8680
  this._shared = new rxjs.Subject();
8681
8681
  this._usernameSelected = new rxjs.Subject();
8682
8682
  this._avatarSelected = new rxjs.Subject();
8683
+ /**
8684
+ * Track whether we created this source. If we did not (ie it was passed in from the caller),
8685
+ * then we are not responsible for calling close(). If we do own it though, we will call close()
8686
+ * when we are done with it.
8687
+ */
8688
+ this._sourceIsOwned = false;
8683
8689
  this._subs = new rxjs.Subscription();
8684
8690
  this._sortOrder = common$1.CommentsOrder.NEWEST;
8685
8691
  this.selectedMessageVisible = false;
@@ -8799,13 +8805,8 @@
8799
8805
  return __awaiter(this, void 0, void 0, function () {
8800
8806
  var _this = this;
8801
8807
  return __generator(this, function (_d) {
8802
- if (this._source) {
8803
- this._source.close();
8804
- this._source = null;
8805
- }
8806
8808
  setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
8807
8809
  var _d;
8808
- var _this = this;
8809
8810
  return __generator(this, function (_e) {
8810
8811
  switch (_e.label) {
8811
8812
  case 0:
@@ -8813,14 +8814,8 @@
8813
8814
  _d = this;
8814
8815
  return [4 /*yield*/, this.backend.getSourceForTopic(topicID, { sortOrder: this.sortOrder })];
8815
8816
  case 1:
8816
- _d._source = _e.sent();
8817
- if (this.sharedCommentID) {
8818
- this.navigateToSharedComment(this.sharedCommentID);
8819
- this.sharedCommentID = null;
8820
- }
8821
- this._source.messageReceived.subscribe(function (m) { return _this.addParticipant(m); });
8822
- this._source.messageSent.subscribe(function (m) { return _this.addParticipant(m); });
8823
- this._source.messages.forEach(function (m) { return _this.addParticipant(m); });
8817
+ _d.source = _e.sent();
8818
+ this._sourceIsOwned = true;
8824
8819
  return [2 /*return*/];
8825
8820
  }
8826
8821
  });
@@ -8903,10 +8898,35 @@
8903
8898
  Object.defineProperty(BantaCommentsComponent.prototype, "source", {
8904
8899
  get: function () { return this._source; },
8905
8900
  set: function (value) {
8901
+ var _this = this;
8902
+ var _a;
8903
+ if (this._source && this._sourceIsOwned) {
8904
+ this._source.close();
8905
+ (_a = this._sourceSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
8906
+ this._source = null;
8907
+ this.participants = [];
8908
+ }
8906
8909
  this._source = value;
8907
- if (value && this.sharedCommentID) {
8908
- this.navigateToSharedComment(this.sharedCommentID);
8909
- this.sharedCommentID = null;
8910
+ this._sourceIsOwned = false; // Assume we don't own this source.
8911
+ this._sourceSubscription = new rxjs.Subscription();
8912
+ if (value) {
8913
+ if (this.sharedCommentID) {
8914
+ this.navigateToSharedComment(this.sharedCommentID);
8915
+ this.sharedCommentID = null;
8916
+ }
8917
+ this._source.messages.forEach(function (m) { return _this.addParticipant(m); });
8918
+ this._sourceSubscription.add(this._source.messageReceived.subscribe(function (m) { return _this.addParticipant(m); }));
8919
+ this._sourceSubscription.add(this._source.messageSent.subscribe(function (m) { return _this.addParticipant(m); }));
8920
+ this._sourceSubscription.add(this._source.messageUpdated.subscribe(function (msg) {
8921
+ var _a;
8922
+ console.log("comments received message: ", msg);
8923
+ if (msg.id === ((_a = _this.selectedMessage) === null || _a === void 0 ? void 0 : _a.id) && msg.hidden) {
8924
+ _this.unselectMessage();
8925
+ _this.matSnackBar.open("The thread you were viewing was removed.", undefined, {
8926
+ duration: 2500
8927
+ });
8928
+ }
8929
+ }));
8910
8930
  }
8911
8931
  },
8912
8932
  enumerable: false,
@@ -9337,7 +9357,8 @@
9337
9357
  BantaCommentsComponent.ctorParameters = function () { return [
9338
9358
  { type: ChatBackendBase },
9339
9359
  { type: core.ElementRef },
9340
- { type: router.ActivatedRoute }
9360
+ { type: router.ActivatedRoute },
9361
+ { type: snackBar.MatSnackBar }
9341
9362
  ]; };
9342
9363
  BantaCommentsComponent.propDecorators = {
9343
9364
  loadingMessages: [{ type: core.Input }],
@@ -9921,6 +9942,7 @@
9921
9942
  _this.state = 'connecting';
9922
9943
  _this.messageMap = new Map();
9923
9944
  _this._messageReceived = new rxjs.Subject();
9945
+ _this._messageUpdated = new rxjs.Subject();
9924
9946
  _this._messageSent = new rxjs.Subject();
9925
9947
  _this.messages = [];
9926
9948
  _this.ready = new Promise(function (resolve) { return _this.markReady = resolve; });
@@ -10043,6 +10065,7 @@
10043
10065
  ChatSource.prototype.onChatMessage = function (message) {
10044
10066
  if (this.messageMap.has(message.id)) {
10045
10067
  Object.assign(this.messageMap.get(message.id), message);
10068
+ this._messageUpdated.next(message);
10046
10069
  }
10047
10070
  else if (!message.hidden) {
10048
10071
  // Only process non-hidden messages through here.
@@ -10057,6 +10080,11 @@
10057
10080
  enumerable: false,
10058
10081
  configurable: true
10059
10082
  });
10083
+ Object.defineProperty(ChatSource.prototype, "messageUpdated", {
10084
+ get: function () { return this._messageUpdated.asObservable(); },
10085
+ enumerable: false,
10086
+ configurable: true
10087
+ });
10060
10088
  Object.defineProperty(ChatSource.prototype, "messageSent", {
10061
10089
  get: function () { return this._messageSent.asObservable(); },
10062
10090
  enumerable: false,
@@ -10300,7 +10328,8 @@
10300
10328
  dialog.MatDialogModule,
10301
10329
  formField.MatFormFieldModule,
10302
10330
  input.MatInputModule,
10303
- progressSpinner.MatProgressSpinnerModule
10331
+ progressSpinner.MatProgressSpinnerModule,
10332
+ snackBar.MatSnackBarModule
10304
10333
  ],
10305
10334
  declarations: [
10306
10335
  BantaComponent,