@banta/sdk 4.0.11 → 4.0.14

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) {
@@ -7124,7 +7124,13 @@
7124
7124
  this.panelElement.nativeElement.remove();
7125
7125
  };
7126
7126
  EmojiSelectorButtonComponent.prototype.ngAfterViewInit = function () {
7127
- var root = document.body.querySelector('[ng-version]') || document.body;
7127
+ this.putPanelAtRoot();
7128
+ };
7129
+ EmojiSelectorButtonComponent.prototype.putPanelAtRoot = function () {
7130
+ // If we are in full-screen, placing the panel outside of the full-screen element will result in it
7131
+ // always being behind said full-screen element, so we need to ensure we never place it further up the
7132
+ // stack.
7133
+ var root = document.fullscreenElement || document.body.querySelector('[ng-version]') || document.body;
7128
7134
  root.appendChild(this.panelElement.nativeElement);
7129
7135
  };
7130
7136
  EmojiSelectorButtonComponent.prototype.removeListener = function () {
@@ -7132,6 +7138,7 @@
7132
7138
  window.removeEventListener('resize', this.resizeListener);
7133
7139
  };
7134
7140
  EmojiSelectorButtonComponent.prototype.place = function () {
7141
+ this.putPanelAtRoot();
7135
7142
  var pos = this.buttonElement.nativeElement.getBoundingClientRect();
7136
7143
  var size = this.panelElement.nativeElement.getBoundingClientRect();
7137
7144
  var left = window.scrollX + pos.left + pos.width - size.width;
@@ -8294,7 +8301,6 @@
8294
8301
  };
8295
8302
  CommentComponent.prototype.avatarForUser = function (user) {
8296
8303
  var url = this.genericAvatarUrl;
8297
- console.log("GENERIC: " + this.genericAvatarUrl);
8298
8304
  if (user && user.avatarUrl) {
8299
8305
  url = user.avatarUrl;
8300
8306
  }
@@ -8650,11 +8656,12 @@
8650
8656
  * Comments component
8651
8657
  */
8652
8658
  var BantaCommentsComponent = /** @class */ (function () {
8653
- function BantaCommentsComponent(backend, elementRef, activatedRoute) {
8659
+ function BantaCommentsComponent(backend, elementRef, activatedRoute, matSnackBar) {
8654
8660
  var _this = this;
8655
8661
  this.backend = backend;
8656
8662
  this.elementRef = elementRef;
8657
8663
  this.activatedRoute = activatedRoute;
8664
+ this.matSnackBar = matSnackBar;
8658
8665
  // Loading Screen
8659
8666
  this._loadingMessage = '';
8660
8667
  this.loadingMessageVisible = false;
@@ -8680,6 +8687,12 @@
8680
8687
  this._shared = new rxjs.Subject();
8681
8688
  this._usernameSelected = new rxjs.Subject();
8682
8689
  this._avatarSelected = new rxjs.Subject();
8690
+ /**
8691
+ * Track whether we created this source. If we did not (ie it was passed in from the caller),
8692
+ * then we are not responsible for calling close(). If we do own it though, we will call close()
8693
+ * when we are done with it.
8694
+ */
8695
+ this._sourceIsOwned = false;
8683
8696
  this._subs = new rxjs.Subscription();
8684
8697
  this._sortOrder = common$1.CommentsOrder.NEWEST;
8685
8698
  this.selectedMessageVisible = false;
@@ -8799,13 +8812,8 @@
8799
8812
  return __awaiter(this, void 0, void 0, function () {
8800
8813
  var _this = this;
8801
8814
  return __generator(this, function (_d) {
8802
- if (this._source) {
8803
- this._source.close();
8804
- this._source = null;
8805
- }
8806
8815
  setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
8807
8816
  var _d;
8808
- var _this = this;
8809
8817
  return __generator(this, function (_e) {
8810
8818
  switch (_e.label) {
8811
8819
  case 0:
@@ -8813,14 +8821,8 @@
8813
8821
  _d = this;
8814
8822
  return [4 /*yield*/, this.backend.getSourceForTopic(topicID, { sortOrder: this.sortOrder })];
8815
8823
  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); });
8824
+ _d.source = _e.sent();
8825
+ this._sourceIsOwned = true;
8824
8826
  return [2 /*return*/];
8825
8827
  }
8826
8828
  });
@@ -8903,10 +8905,35 @@
8903
8905
  Object.defineProperty(BantaCommentsComponent.prototype, "source", {
8904
8906
  get: function () { return this._source; },
8905
8907
  set: function (value) {
8908
+ var _this = this;
8909
+ var _a;
8910
+ if (this._source && this._sourceIsOwned) {
8911
+ this._source.close();
8912
+ (_a = this._sourceSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
8913
+ this._source = null;
8914
+ this.participants = [];
8915
+ }
8906
8916
  this._source = value;
8907
- if (value && this.sharedCommentID) {
8908
- this.navigateToSharedComment(this.sharedCommentID);
8909
- this.sharedCommentID = null;
8917
+ this._sourceIsOwned = false; // Assume we don't own this source.
8918
+ this._sourceSubscription = new rxjs.Subscription();
8919
+ if (value) {
8920
+ if (this.sharedCommentID) {
8921
+ this.navigateToSharedComment(this.sharedCommentID);
8922
+ this.sharedCommentID = null;
8923
+ }
8924
+ this._source.messages.forEach(function (m) { return _this.addParticipant(m); });
8925
+ this._sourceSubscription.add(this._source.messageReceived.subscribe(function (m) { return _this.addParticipant(m); }));
8926
+ this._sourceSubscription.add(this._source.messageSent.subscribe(function (m) { return _this.addParticipant(m); }));
8927
+ this._sourceSubscription.add(this._source.messageUpdated.subscribe(function (msg) {
8928
+ var _a;
8929
+ console.log("comments received message: ", msg);
8930
+ if (msg.id === ((_a = _this.selectedMessage) === null || _a === void 0 ? void 0 : _a.id) && msg.hidden) {
8931
+ _this.unselectMessage();
8932
+ _this.matSnackBar.open("The thread you were viewing was removed.", undefined, {
8933
+ duration: 2500
8934
+ });
8935
+ }
8936
+ }));
8910
8937
  }
8911
8938
  },
8912
8939
  enumerable: false,
@@ -9337,7 +9364,8 @@
9337
9364
  BantaCommentsComponent.ctorParameters = function () { return [
9338
9365
  { type: ChatBackendBase },
9339
9366
  { type: core.ElementRef },
9340
- { type: router.ActivatedRoute }
9367
+ { type: router.ActivatedRoute },
9368
+ { type: snackBar.MatSnackBar }
9341
9369
  ]; };
9342
9370
  BantaCommentsComponent.propDecorators = {
9343
9371
  loadingMessages: [{ type: core.Input }],
@@ -9862,7 +9890,7 @@
9862
9890
  { type: core.Component, args: [{
9863
9891
  selector: 'banta-attachment-button',
9864
9892
  template: "<button matTooltip=\"Add an image or gif\" #button type=\"button\" mat-icon-button (click)=\"show()\">\r\n\t<mat-icon>image</mat-icon>\r\n</button>\r\n<input style=\"display: none;\" #fileUpload [multiple]=\"false\" (change)=\"fileChange($event)\" type=\"file\" >",
9865
- styles: [""]
9893
+ styles: ["button{color:#666}"]
9866
9894
  },] }
9867
9895
  ];
9868
9896
  AttachmentButtonComponent.ctorParameters = function () { return [
@@ -9921,6 +9949,7 @@
9921
9949
  _this.state = 'connecting';
9922
9950
  _this.messageMap = new Map();
9923
9951
  _this._messageReceived = new rxjs.Subject();
9952
+ _this._messageUpdated = new rxjs.Subject();
9924
9953
  _this._messageSent = new rxjs.Subject();
9925
9954
  _this.messages = [];
9926
9955
  _this.ready = new Promise(function (resolve) { return _this.markReady = resolve; });
@@ -10043,6 +10072,7 @@
10043
10072
  ChatSource.prototype.onChatMessage = function (message) {
10044
10073
  if (this.messageMap.has(message.id)) {
10045
10074
  Object.assign(this.messageMap.get(message.id), message);
10075
+ this._messageUpdated.next(message);
10046
10076
  }
10047
10077
  else if (!message.hidden) {
10048
10078
  // Only process non-hidden messages through here.
@@ -10057,6 +10087,11 @@
10057
10087
  enumerable: false,
10058
10088
  configurable: true
10059
10089
  });
10090
+ Object.defineProperty(ChatSource.prototype, "messageUpdated", {
10091
+ get: function () { return this._messageUpdated.asObservable(); },
10092
+ enumerable: false,
10093
+ configurable: true
10094
+ });
10060
10095
  Object.defineProperty(ChatSource.prototype, "messageSent", {
10061
10096
  get: function () { return this._messageSent.asObservable(); },
10062
10097
  enumerable: false,
@@ -10300,7 +10335,8 @@
10300
10335
  dialog.MatDialogModule,
10301
10336
  formField.MatFormFieldModule,
10302
10337
  input.MatInputModule,
10303
- progressSpinner.MatProgressSpinnerModule
10338
+ progressSpinner.MatProgressSpinnerModule,
10339
+ snackBar.MatSnackBarModule
10304
10340
  ],
10305
10341
  declarations: [
10306
10342
  BantaComponent,