@banta/sdk 3.2.0 → 3.2.3

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,4 +1,4 @@
1
- import { Observable, Subject, BehaviorSubject } from 'rxjs';
1
+ import { Observable, Subject, BehaviorSubject, Subscription } from 'rxjs';
2
2
  import { publish } from 'rxjs/operators';
3
3
  import { Injectable, Component, Input, NgModule, Output, ViewChild, ElementRef, HostBinding } from '@angular/core';
4
4
  import { CommonModule } from '@angular/common';
@@ -9,7 +9,6 @@ import { MatFormFieldModule } from '@angular/material/form-field';
9
9
  import { MatInputModule } from '@angular/material/input';
10
10
  import { FormsModule } from '@angular/forms';
11
11
  import { __awaiter } from 'tslib';
12
- import { SubSink } from 'subsink';
13
12
  import { MatDialog, MatDialogModule } from '@angular/material/dialog';
14
13
  import { MatMenuModule } from '@angular/material/menu';
15
14
  import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
@@ -7037,7 +7036,7 @@ LiveChatMessageComponent.propDecorators = {
7037
7036
  class ChatViewComponent {
7038
7037
  constructor(elementRef) {
7039
7038
  this.elementRef = elementRef;
7040
- this._sourceSubs = new SubSink();
7039
+ this._sourceSubs = new Subscription();
7041
7040
  this._selected = new Subject();
7042
7041
  this._reported = new Subject();
7043
7042
  this._upvoted = new Subject();
@@ -7068,15 +7067,14 @@ class ChatViewComponent {
7068
7067
  this._source = value;
7069
7068
  this.messages = [];
7070
7069
  if (value) {
7071
- this._sourceSubs = new SubSink();
7070
+ this._sourceSubs = new Subscription();
7072
7071
  this.messages = value.messages.slice();
7073
7072
  console.log(`Source set:`);
7074
7073
  console.dir(value);
7075
7074
  console.log(`Messages loaded:`);
7076
7075
  console.dir(this.messages);
7077
- this._sourceSubs.add(this._source.messageReceived
7078
- .subscribe(msg => this.messageReceived(msg)), this._source.messageSent
7079
- .subscribe(msg => this.messageSent(msg)));
7076
+ this._sourceSubs.add(this._source.messageReceived.subscribe(msg => this.messageReceived(msg)));
7077
+ this._sourceSubs.add(this._source.messageSent.subscribe(msg => this.messageSent(msg)));
7080
7078
  if (this._source.currentUserChanged) {
7081
7079
  this._sourceSubs.add(this._source.currentUserChanged
7082
7080
  .subscribe(user => this.currentUser = user));
@@ -7186,7 +7184,7 @@ class BantaChatComponent {
7186
7184
  this.banta = banta;
7187
7185
  this.backend = backend;
7188
7186
  this.elementRef = elementRef;
7189
- this._subs = new SubSink();
7187
+ this._subs = new Subscription();
7190
7188
  this.user = null;
7191
7189
  this.signInLabel = 'Sign In';
7192
7190
  this.sendLabel = 'Send';
@@ -7295,6 +7293,7 @@ class BantaChatComponent {
7295
7293
  user: null,
7296
7294
  sentAt: Date.now(),
7297
7295
  upvotes: 0,
7296
+ url: location.href,
7298
7297
  message: text
7299
7298
  };
7300
7299
  try {
@@ -7364,7 +7363,7 @@ class BantaComponent {
7364
7363
  this.banta = banta;
7365
7364
  this.backend = backend;
7366
7365
  this.matDialog = matDialog;
7367
- this._subs = new SubSink();
7366
+ this._subs = new Subscription();
7368
7367
  this.auxOpen = false;
7369
7368
  this.auxTitle = 'Notifications';
7370
7369
  this.auxMode = 'notifications';
@@ -7379,7 +7378,9 @@ class BantaComponent {
7379
7378
  this.genericAvatarUrl = 'https://gravatar.com/avatar/915c804e0be607a4ad766ddadea5c48a?s=512&d=https://codepen.io/assets/avatars/user-avatar-512x512-6e240cf350d2f1cc07c2bed234c3a3bb5f1b237023c204c782622e80d6b212ba.png';
7380
7379
  }
7381
7380
  ngOnInit() {
7382
- this._subs.add(this.banta.userChanged.subscribe(user => this.currentUser = user), this.backend.notificationsChanged.subscribe(notifs => this.notifications = notifs), this.backend.newNotification.subscribe(notif => {
7381
+ this._subs.add(this.banta.userChanged.subscribe(user => this.currentUser = user));
7382
+ this._subs.add(this.backend.notificationsChanged.subscribe(notifs => this.notifications = notifs));
7383
+ this._subs.add(this.backend.newNotification.subscribe(notif => {
7383
7384
  this.newNotifications = true;
7384
7385
  }));
7385
7386
  }
@@ -7643,6 +7644,8 @@ class CommentComponent {
7643
7644
  this._selected = new Subject();
7644
7645
  this._upvoted = new Subject();
7645
7646
  this._userSelected = new Subject();
7647
+ this._avatarSelected = new Subject();
7648
+ this._usernameSelected = new Subject();
7646
7649
  this.isNew = false;
7647
7650
  this.visible = false;
7648
7651
  this.showReplyAction = true;
@@ -7658,16 +7661,22 @@ class CommentComponent {
7658
7661
  }, randomTime);
7659
7662
  }
7660
7663
  get userSelected() {
7661
- return this._userSelected;
7664
+ return this._userSelected.asObservable();
7665
+ }
7666
+ get usernameSelected() {
7667
+ return this._usernameSelected.asObservable();
7668
+ }
7669
+ get avatarSelected() {
7670
+ return this._avatarSelected.asObservable();
7662
7671
  }
7663
7672
  get reported() {
7664
- return this._reported;
7673
+ return this._reported.asObservable();
7665
7674
  }
7666
7675
  get upvoted() {
7667
- return this._upvoted;
7676
+ return this._upvoted.asObservable();
7668
7677
  }
7669
7678
  get selected() {
7670
- return this._selected;
7679
+ return this._selected.asObservable();
7671
7680
  }
7672
7681
  get commentId() {
7673
7682
  var _a;
@@ -7683,7 +7692,15 @@ class CommentComponent {
7683
7692
  this._selected.next();
7684
7693
  }
7685
7694
  selectUser() {
7686
- return this._userSelected.next();
7695
+ this._userSelected.next();
7696
+ }
7697
+ selectUsername(user) {
7698
+ this._usernameSelected.next(user);
7699
+ this.selectUser();
7700
+ }
7701
+ selectAvatar(user) {
7702
+ this._avatarSelected.next(user);
7703
+ this.selectUser();
7687
7704
  }
7688
7705
  avatarForUser(user) {
7689
7706
  if (user && user.avatarUrl) {
@@ -7696,7 +7713,7 @@ class CommentComponent {
7696
7713
  CommentComponent.decorators = [
7697
7714
  { type: Component, args: [{
7698
7715
  selector: 'banta-comment',
7699
- template: "\r\n<mat-menu #pointItemMenu=\"matMenu\">\r\n <button mat-menu-item (click)=\"report()\">Report</button>\r\n <button mat-menu-item>Help</button>\r\n</mat-menu>\r\n\r\n<div class=\"message-content\">\r\n <div class=\"user\">\r\n <a \r\n href=\"javascript:;\"\r\n class=\"avatar\"\r\n (click)=\"selectUser()\"\r\n [style.background-image]=\"avatarForUser(message.user)\"></a>\r\n <a href=\"javascript:;\" class=\"display-name\" (click)=\"selectUser()\">{{message.user.displayName}}</a>\r\n <a href=\"javascript:;\" class=\"username\" (click)=\"selectUser()\">@{{message.user.username}}</a>\r\n </div>\r\n <div class=\"content\">\r\n {{message.message}}\r\n </div>\r\n \r\n <div class=\"actions\">\r\n <banta-timestamp [value]=\"message.sentAt\"></banta-timestamp>\r\n <div class=\"spacer\"></div>\r\n <div class=\"counted-action\" *ngIf=\"showReplyAction\">\r\n <div class=\"count-indicator\">\r\n {{message.submessages?.length || 0}}\r\n </div>\r\n <button mat-icon-button matTooltip=\"Comment\" matTooltipPosition=\"below\" (click)=\"select()\">\r\n <mat-icon [inline]=\"true\">comment</mat-icon>\r\n </button>\r\n </div>\r\n <div class=\"counted-action\">\r\n <div class=\"count-indicator\"> \r\n {{message.upvotes}}\r\n </div>\r\n <button mat-icon-button matTooltip=\"Upvote\" matTooltipPosition=\"below\" (click)=\"upvote()\">\r\n <mat-icon [inline]=\"true\">thumb_up</mat-icon>\r\n </button>\r\n </div>\r\n \r\n <button mat-icon-button [matMenuTriggerFor]=\"pointItemMenu\">\r\n <mat-icon [inline]=\"true\">more_vert</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n",
7716
+ template: "\r\n<mat-menu #pointItemMenu=\"matMenu\">\r\n <button mat-menu-item (click)=\"report()\">Report</button>\r\n <button mat-menu-item>Help</button>\r\n</mat-menu>\r\n\r\n<div class=\"message-content\">\r\n <div class=\"user\">\r\n <a \r\n href=\"javascript:;\"\r\n class=\"avatar\"\r\n (click)=\"selectAvatar(message.user)\"\r\n [style.background-image]=\"avatarForUser(message.user)\"></a>\r\n <a href=\"javascript:;\" class=\"display-name\" (click)=\"selectUser()\">{{message.user.displayName}}</a>\r\n <a href=\"javascript:;\" class=\"username\" (click)=\"selectUsername(message.user)\">@{{message.user.username}}</a>\r\n </div>\r\n <div class=\"content\">\r\n {{message.message}}\r\n </div>\r\n \r\n <div class=\"actions\">\r\n <banta-timestamp [value]=\"message.sentAt\"></banta-timestamp>\r\n <div class=\"spacer\"></div>\r\n <div class=\"counted-action\" *ngIf=\"showReplyAction\">\r\n <div class=\"count-indicator\">\r\n {{message.submessages?.length || 0}}\r\n </div>\r\n <button mat-icon-button matTooltip=\"Comment\" matTooltipPosition=\"below\" (click)=\"select()\">\r\n <mat-icon [inline]=\"true\">comment</mat-icon>\r\n </button>\r\n </div>\r\n <div class=\"counted-action\">\r\n <div class=\"count-indicator\"> \r\n {{message.upvotes}}\r\n </div>\r\n <button mat-icon-button matTooltip=\"Upvote\" matTooltipPosition=\"below\" (click)=\"upvote()\">\r\n <mat-icon [inline]=\"true\">thumb_up</mat-icon>\r\n </button>\r\n </div>\r\n \r\n <button mat-icon-button [matMenuTriggerFor]=\"pointItemMenu\">\r\n <mat-icon [inline]=\"true\">more_vert</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n",
7700
7717
  styles: ["@-webkit-keyframes comment-appear{0%{transform:translate(100vw)}to{transform:translate(0)}}@keyframes comment-appear{0%{transform:translate(100vw)}to{transform:translate(0)}}:host{display:flex;flex-direction:column;padding:.5em;position:relative;visibility:hidden}:host.new{-webkit-animation-duration:.4s;-webkit-animation-fill-mode:both;-webkit-animation-name:comment-appear;animation-duration:.4s;animation-fill-mode:both;animation-name:comment-appear}:host.new,:host.visible{visibility:visible}:host:hover{background:#eee}:host .message-content .content{margin-left:60px;margin-right:.5em}:host.abbreviated .message-content .content{max-height:8.5em;overflow-y:hidden;text-overflow:ellipsis}:host .actions{align-items:center;display:flex;margin-left:60px;padding-right:10px}:host .actions button{color:#666}:host .actions banta-timestamp{color:#666;font-size:10pt}.user{align-items:center;display:flex;margin:1em 0 0;position:relative}.user .display-name,.user .username{color:#000;display:block;flex-grow:0;flex-shrink:1;font-size:10pt;margin:0 auto 0 0;max-width:100%;overflow:hidden;padding:0 0 0 1em;position:relative;text-overflow:ellipsis;white-space:nowrap;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;z-index:1}.user .display-name.username,.user .username.username{color:#666;flex-grow:1;flex-shrink:0}.avatar{background-color:#333;background-position:50%;background-size:cover;border-radius:100%;flex-grow:0;flex-shrink:0;height:48px;width:48px}.counted-action{align-items:center;display:flex}.count-indicator{color:#666;font-size:9pt;padding:0 0 0 3px}:host-context(.mat-dark-theme) .count-indicator{border-color:#333}:host-context(.mat-dark-theme):hover{background:#060606}:host-context(.mat-dark-theme) .user .display-name,:host-context(.mat-dark-theme) .user .username{color:#fff}@media (max-width:400px){.avatar{height:32px;width:32px}:host .actions{margin-left:44px}:host .message-content .content{margin-left:44px;margin-right:.5em}}"]
7701
7718
  },] }
7702
7719
  ];
@@ -7706,6 +7723,8 @@ CommentComponent.propDecorators = {
7706
7723
  message: [{ type: Input }],
7707
7724
  showReplyAction: [{ type: Input }],
7708
7725
  userSelected: [{ type: Output }],
7726
+ usernameSelected: [{ type: Output }],
7727
+ avatarSelected: [{ type: Output }],
7709
7728
  reported: [{ type: Output }],
7710
7729
  upvoted: [{ type: Output }],
7711
7730
  selected: [{ type: Output }],
@@ -7715,11 +7734,13 @@ CommentComponent.propDecorators = {
7715
7734
  class CommentViewComponent {
7716
7735
  constructor(backend) {
7717
7736
  this.backend = backend;
7718
- this._sourceSubs = new SubSink();
7737
+ this._sourceSubs = new Subscription();
7719
7738
  this._selected = new Subject();
7720
7739
  this._upvoted = new Subject();
7721
7740
  this._reported = new Subject();
7722
7741
  this._userSelected = new Subject();
7742
+ this._usernameSelected = new Subject();
7743
+ this._avatarSelected = new Subject();
7723
7744
  this.showEmptyState = true;
7724
7745
  this.allowReplies = true;
7725
7746
  this.menuMessage = null;
@@ -7745,6 +7766,12 @@ class CommentViewComponent {
7745
7766
  get upvoted() {
7746
7767
  return this._upvoted;
7747
7768
  }
7769
+ get usernameSelected() {
7770
+ return this._usernameSelected;
7771
+ }
7772
+ get avatarSelected() {
7773
+ return this._avatarSelected;
7774
+ }
7748
7775
  get source() {
7749
7776
  return this._source;
7750
7777
  }
@@ -7755,13 +7782,17 @@ class CommentViewComponent {
7755
7782
  this._reported.next(message);
7756
7783
  }
7757
7784
  selectMessage(message) {
7758
- return __awaiter(this, void 0, void 0, function* () {
7759
- this._selected.next(message);
7760
- });
7785
+ this._selected.next(message);
7761
7786
  }
7762
7787
  selectMessageUser(message) {
7763
7788
  this._userSelected.next(message);
7764
7789
  }
7790
+ selectUsername(user) {
7791
+ this._usernameSelected.next(user);
7792
+ }
7793
+ selectAvatar(user) {
7794
+ this._avatarSelected.next(user);
7795
+ }
7765
7796
  set source(value) {
7766
7797
  if (this._sourceSubs) {
7767
7798
  this._sourceSubs.unsubscribe();
@@ -7773,10 +7804,9 @@ class CommentViewComponent {
7773
7804
  this.messages = messages;
7774
7805
  this.olderMessages = messages.splice(this.maxVisibleMessages, messages.length);
7775
7806
  this.hasMore = this.olderMessages.length > 0;
7776
- this._sourceSubs = new SubSink();
7777
- this._sourceSubs.add(this._source.messageReceived
7778
- .subscribe(msg => this.messageReceived(msg)), this._source.messageSent
7779
- .subscribe(msg => this.messageSent(msg)));
7807
+ this._sourceSubs = new Subscription();
7808
+ this._sourceSubs.add(this._source.messageReceived.subscribe(msg => this.messageReceived(msg)));
7809
+ this._sourceSubs.add(this._source.messageSent.subscribe(msg => this.messageSent(msg)));
7780
7810
  if (this._source.currentUserChanged) {
7781
7811
  this._sourceSubs.add(this._source.currentUserChanged.subscribe(user => this.currentUser = user));
7782
7812
  }
@@ -7879,7 +7909,7 @@ class CommentViewComponent {
7879
7909
  CommentViewComponent.decorators = [
7880
7910
  { type: Component, args: [{
7881
7911
  selector: 'banta-comment-view',
7882
- template: "<div class=\"message-container\">\r\n <ng-content select=\"[data-before]\"></ng-content>\r\n \r\n <a mat-button class=\"nav\" [class.visible]=\"isViewingMore\" href=\"javascript:;\" (click)=\"showNew()\">\r\n <mat-icon>file_upload</mat-icon>\r\n New\r\n <ng-container *ngIf=\"newMessages.length >= 1\">\r\n ({{newMessages.length}})\r\n </ng-container>\r\n </a>\r\n\r\n <ng-container *ngIf=\"messages.length === 0\">\r\n <div class=\"empty-state\" *ngIf=\"showEmptyState\">\r\n Be the first to comment!\r\n </div>\r\n </ng-container>\r\n <banta-comment \r\n *ngFor=\"let message of messages; trackBy: messageIdentity\"\r\n class=\"abbreviated\"\r\n [message]=\"message\"\r\n (click)=\"isViewingMore = true\"\r\n [showReplyAction]=\"allowReplies\"\r\n (userSelected)=\"selectMessageUser(message)\"\r\n (upvoted)=\"upvoteMessage(message)\"\r\n (reported)=\"reportMessage(message)\"\r\n (selected)=\"selectMessage(message)\"\r\n ></banta-comment>\r\n\r\n <a mat-button class=\"nav\" [class.visible]=\"hasMore && !isLoadingMore\" href=\"javascript:;\" (click)=\"showMore()\">Show more</a>\r\n\r\n <div class=\"loading-more\" *ngIf=\"isLoadingMore\">\r\n <mat-spinner></mat-spinner>\r\n </div>\r\n\r\n <!-- <div style=\"color: #666\">\r\n n={{newMessages.length}}, m={{messages.length}}, o={{olderMessages.length}},\r\n v={{maxVisibleMessages}}, M={{maxMessages}}\r\n </div> -->\r\n\r\n <ng-content select=\":not([data-before])\"></ng-content>\r\n</div>",
7912
+ template: "<div class=\"message-container\">\r\n <ng-content select=\"[data-before]\"></ng-content>\r\n \r\n <a mat-button class=\"nav\" [class.visible]=\"isViewingMore\" href=\"javascript:;\" (click)=\"showNew()\">\r\n <mat-icon>file_upload</mat-icon>\r\n New\r\n <ng-container *ngIf=\"newMessages.length >= 1\">\r\n ({{newMessages.length}})\r\n </ng-container>\r\n </a>\r\n\r\n <ng-container *ngIf=\"messages.length === 0\">\r\n <div class=\"empty-state\" *ngIf=\"showEmptyState\">\r\n Be the first to comment!\r\n </div>\r\n </ng-container>\r\n <banta-comment \r\n *ngFor=\"let message of messages; trackBy: messageIdentity\"\r\n class=\"abbreviated\"\r\n [message]=\"message\"\r\n (click)=\"isViewingMore = true\"\r\n [showReplyAction]=\"allowReplies\"\r\n\t\t(userSelected)=\"selectMessageUser(message)\"\r\n (avatarSelected)=\"selectAvatar($event)\"\r\n\t\t(usernameSelected)=\"selectUsername($event)\"\r\n (upvoted)=\"upvoteMessage(message)\"\r\n (reported)=\"reportMessage(message)\"\r\n (selected)=\"selectMessage(message)\"\r\n ></banta-comment>\r\n\r\n <a mat-button class=\"nav\" [class.visible]=\"hasMore && !isLoadingMore\" href=\"javascript:;\" (click)=\"showMore()\">Show more</a>\r\n\r\n <div class=\"loading-more\" *ngIf=\"isLoadingMore\">\r\n <mat-spinner></mat-spinner>\r\n </div>\r\n\r\n <!-- <div style=\"color: #666\">\r\n n={{newMessages.length}}, m={{messages.length}}, o={{olderMessages.length}},\r\n v={{maxVisibleMessages}}, M={{maxMessages}}\r\n </div> -->\r\n\r\n <ng-content select=\":not([data-before])\"></ng-content>\r\n</div>",
7883
7913
  styles: [":host{display:flex;flex-direction:column;flex-grow:1;opacity:1;transition:opacity .2s ease-in}.message-container{background:#fff;color:#111;flex-grow:1;opacity:1;overflow-x:hidden;padding:.5em 1em 3em .5em;position:relative;transition:opacity .5s ease-in-out}.message-container.no-scroll{height:auto;overflow-y:visible}.message-container.faded{opacity:.25}.message-container .overlay{bottom:0;left:0;position:absolute;right:0;top:0;z-index:10}:host.fixed-height .message-container{overflow-y:auto}:host-context(.mat-dark-theme) .message-container{background:#111;color:#fff}.empty-state{color:#666;margin:3em;text-align:center}:host-context(.mat-dark-theme) .empty-state{color:#666}a.nav{background:#222;border-radius:2em;opacity:0;pointer-events:none;position:absolute;right:.5em;text-align:center;transition:opacity .4s ease-in-out;z-index:10}a.nav.visible{opacity:1;pointer-events:auto}.loading-more{margin:0 auto;padding:2em;text-align:center;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}@media (max-width:400px){.message-container{padding:0 0 3em}}"]
7884
7914
  },] }
7885
7915
  ];
@@ -7894,6 +7924,8 @@ CommentViewComponent.propDecorators = {
7894
7924
  userSelected: [{ type: Output }],
7895
7925
  reported: [{ type: Output }],
7896
7926
  upvoted: [{ type: Output }],
7927
+ usernameSelected: [{ type: Output }],
7928
+ avatarSelected: [{ type: Output }],
7897
7929
  source: [{ type: Input }],
7898
7930
  genericAvatarUrl: [{ type: Input }],
7899
7931
  messageContainer: [{ type: ViewChild, args: ['messageContainer',] }],
@@ -7914,7 +7946,9 @@ class BantaCommentsComponent {
7914
7946
  this._reported = new Subject();
7915
7947
  this._selected = new Subject();
7916
7948
  this._userSelected = new Subject();
7917
- this._subs = new SubSink();
7949
+ this._usernameSelected = new Subject();
7950
+ this._avatarSelected = new Subject();
7951
+ this._subs = new Subscription();
7918
7952
  this.hashtags = [
7919
7953
  { hashtag: 'error', description: 'Cause an error' },
7920
7954
  { hashtag: 'timeout', description: 'Cause a slow timeout error' },
@@ -8009,16 +8043,22 @@ class BantaCommentsComponent {
8009
8043
  return (_a = this.user.permissions) === null || _a === void 0 ? void 0 : _a.canComment(this.source);
8010
8044
  }
8011
8045
  get upvoted() {
8012
- return this._upvoted;
8046
+ return this._upvoted.asObservable();
8013
8047
  }
8014
8048
  get reported() {
8015
- return this._reported;
8049
+ return this._reported.asObservable();
8016
8050
  }
8017
8051
  get selected() {
8018
- return this._selected;
8052
+ return this._selected.asObservable();
8019
8053
  }
8020
8054
  get userSelected() {
8021
- return this._userSelected;
8055
+ return this._userSelected.asObservable();
8056
+ }
8057
+ get usernameSelected() {
8058
+ return this._usernameSelected.asObservable();
8059
+ }
8060
+ get avatarSelected() {
8061
+ return this._avatarSelected.asObservable();
8022
8062
  }
8023
8063
  onKeyDown(event) {
8024
8064
  }
@@ -8039,37 +8079,6 @@ class BantaCommentsComponent {
8039
8079
  }, 5 * 1000);
8040
8080
  });
8041
8081
  }
8042
- sendMessage() {
8043
- return __awaiter(this, void 0, void 0, function* () {
8044
- if (!this.source)
8045
- return;
8046
- this.sending = true;
8047
- this.sendError = null;
8048
- try {
8049
- let text = (this.newMessageText || '').trim();
8050
- if (text === '')
8051
- return;
8052
- let message = {
8053
- user: this.user,
8054
- sentAt: Date.now(),
8055
- upvotes: 0,
8056
- message: text
8057
- };
8058
- try {
8059
- yield this.source.send(message);
8060
- this.newMessageText = '';
8061
- }
8062
- catch (e) {
8063
- this.indicateError(`Could not send: ${e.message}`);
8064
- console.error(`Failed to send message: `, message);
8065
- console.error(e);
8066
- }
8067
- }
8068
- finally {
8069
- this.sending = false;
8070
- }
8071
- });
8072
- }
8073
8082
  upvoteMessage(message) {
8074
8083
  return __awaiter(this, void 0, void 0, function* () {
8075
8084
  this._upvoted.next(message);
@@ -8106,6 +8115,12 @@ class BantaCommentsComponent {
8106
8115
  selectMessageUser(message) {
8107
8116
  this._userSelected.next(message);
8108
8117
  }
8118
+ selectUsername(user) {
8119
+ this._usernameSelected.next(user);
8120
+ }
8121
+ selectAvatar(user) {
8122
+ this._avatarSelected.next(user);
8123
+ }
8109
8124
  sendReply() {
8110
8125
  return __awaiter(this, void 0, void 0, function* () {
8111
8126
  yield this.selectedMessageThread.send({
@@ -8131,7 +8146,7 @@ class BantaCommentsComponent {
8131
8146
  BantaCommentsComponent.decorators = [
8132
8147
  { type: Component, args: [{
8133
8148
  selector: 'banta-comments',
8134
- template: "\r\n<div class=\"focused\" [class.visible]=\"selectedMessageVisible\" *ngIf=\"selectedMessage\">\r\n\r\n <div>\r\n <a mat-button href=\"javascript:;\" (click)=\"unselectMessage()\">\r\n <mat-icon>arrow_back</mat-icon>\r\n Latest Comments\r\n </a>\r\n </div>\r\n\r\n <banta-comment \r\n [message]=\"selectedMessage\"\r\n ></banta-comment>\r\n\r\n <div class=\"replies\">\r\n\r\n <ng-container *ngIf=\"!selectedMessageThread\">\r\n <div class=\"loading\">\r\n <mat-spinner></mat-spinner>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"selectedMessageThread\">\r\n <banta-comment-view \r\n [source]=\"selectedMessageThread\"\r\n [allowReplies]=\"false\"\r\n [fixedHeight]=\"false\"\r\n [showEmptyState]=\"false\"\r\n [newestLast]=\"true\"\r\n ></banta-comment-view>\r\n\r\n <banta-comment-field\r\n [sendLabel]=\"replyLabel\"\r\n [sendingLabel]=\"sendingLabel\"\r\n [hashtags]=\"hashtags\"\r\n [participants]=\"participants\"\r\n (signInSelected)=\"showSignIn()\"\r\n (editAvatarSelected)=\"showEditAvatar()\"\r\n [source]=\"selectedMessageThread\"\r\n [canComment]=\"canComment\"\r\n [signInLabel]=\"signInLabel\"\r\n [permissionDeniedLabel]=\"permissionDeniedLabel\"\r\n (permissionDeniedError)=\"showPermissionDenied()\"\r\n [user]=\"user\"\r\n [label]=\"postReplyLabel\"\r\n ></banta-comment-field>\r\n </ng-container>\r\n </div>\r\n</div>\r\n\r\n<div class=\"main\" [class.hidden]=\"selectedMessage\">\r\n <banta-comment-field\r\n [source]=\"source\"\r\n [user]=\"user\"\r\n [sendLabel]=\"sendLabel\"\r\n [sendingLabel]=\"sendingLabel\"\r\n [signInLabel]=\"signInLabel\"\r\n [canComment]=\"canComment\"\r\n [hashtags]=\"hashtags\"\r\n [participants]=\"participants\"\r\n [label]=\"postCommentLabel\"\r\n (editAvatarSelected)=\"showEditAvatar()\"\r\n (signInSelected)=\"showSignIn()\"\r\n ></banta-comment-field>\r\n\r\n <banta-comment-view \r\n [class.faded]=\"selectedMessage\"\r\n [source]=\"source\"\r\n [fixedHeight]=\"fixedHeight\"\r\n [maxMessages]=\"maxMessages\"\r\n [maxVisibleMessages]=\"maxVisibleMessages\"\r\n [genericAvatarUrl]=\"genericAvatarUrl\"\r\n (userSelected)=\"selectMessageUser($event)\"\r\n (selected)=\"selectMessage($event)\"\r\n (upvoted)=\"upvoteMessage($event)\"\r\n (reported)=\"reportMessage($event)\"\r\n ></banta-comment-view>\r\n</div>",
8149
+ template: "\r\n<div class=\"focused\" [class.visible]=\"selectedMessageVisible\" *ngIf=\"selectedMessage\">\r\n\r\n <div>\r\n <a mat-button href=\"javascript:;\" (click)=\"unselectMessage()\">\r\n <mat-icon>arrow_back</mat-icon>\r\n Latest Comments\r\n </a>\r\n </div>\r\n\r\n <banta-comment \r\n [message]=\"selectedMessage\"\r\n ></banta-comment>\r\n\r\n <div class=\"replies\">\r\n\r\n <ng-container *ngIf=\"!selectedMessageThread\">\r\n <div class=\"loading\">\r\n <mat-spinner></mat-spinner>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"selectedMessageThread\">\r\n <banta-comment-view \r\n [source]=\"selectedMessageThread\"\r\n [allowReplies]=\"false\"\r\n [fixedHeight]=\"false\"\r\n [showEmptyState]=\"false\"\r\n [newestLast]=\"true\"\r\n ></banta-comment-view>\r\n\r\n <banta-comment-field\r\n [sendLabel]=\"replyLabel\"\r\n [sendingLabel]=\"sendingLabel\"\r\n [hashtags]=\"hashtags\"\r\n [participants]=\"participants\"\r\n (signInSelected)=\"showSignIn()\"\r\n (editAvatarSelected)=\"showEditAvatar()\"\r\n [source]=\"selectedMessageThread\"\r\n [canComment]=\"canComment\"\r\n [signInLabel]=\"signInLabel\"\r\n [permissionDeniedLabel]=\"permissionDeniedLabel\"\r\n (permissionDeniedError)=\"showPermissionDenied()\"\r\n [user]=\"user\"\r\n [label]=\"postReplyLabel\"\r\n ></banta-comment-field>\r\n </ng-container>\r\n </div>\r\n</div>\r\n\r\n<div class=\"main\" [class.hidden]=\"selectedMessage\">\r\n <banta-comment-field\r\n [source]=\"source\"\r\n [user]=\"user\"\r\n [sendLabel]=\"sendLabel\"\r\n [sendingLabel]=\"sendingLabel\"\r\n [signInLabel]=\"signInLabel\"\r\n [canComment]=\"canComment\"\r\n [hashtags]=\"hashtags\"\r\n [participants]=\"participants\"\r\n [label]=\"postCommentLabel\"\r\n (editAvatarSelected)=\"showEditAvatar()\"\r\n (signInSelected)=\"showSignIn()\"\r\n [permissionDeniedLabel]=\"permissionDeniedLabel\"\r\n (permissionDeniedError)=\"showPermissionDenied()\"\r\n ></banta-comment-field>\r\n\r\n <banta-comment-view \r\n [class.faded]=\"selectedMessage\"\r\n [source]=\"source\"\r\n [fixedHeight]=\"fixedHeight\"\r\n [maxMessages]=\"maxMessages\"\r\n [maxVisibleMessages]=\"maxVisibleMessages\"\r\n [genericAvatarUrl]=\"genericAvatarUrl\"\r\n (userSelected)=\"selectMessageUser($event)\"\r\n (selected)=\"selectMessage($event)\"\r\n (upvoted)=\"upvoteMessage($event)\"\r\n (reported)=\"reportMessage($event)\"\r\n (usernameSelected)=\"selectUsername($event)\"\r\n (avatarSelected)=\"selectAvatar($event)\"\r\n ></banta-comment-view>\r\n</div>\r\n",
8135
8150
  styles: [":host{display:flex;flex-direction:column}@-webkit-keyframes select-comment{0%{transform:scale(1.15)}to{transform:scale(1)}}@keyframes select-comment{0%{transform:scale(1.15)}to{transform:scale(1)}}.focused{-webkit-animation-duration:.4s;-webkit-animation-fill-mode:both;-webkit-animation-name:select-comment;animation-duration:.4s;animation-fill-mode:both;animation-name:select-comment}.focused .replies{margin-left:4em;margin-top:1em}banta-comment-view{opacity:1;transition:opacity .4s ease-in-out}banta-comment-view.faded{opacity:.25}.loading{display:block;margin:0 auto;min-height:16em;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}.main.hidden{display:none}@media (max-width:500px){.focused .replies{margin-left:0}}"]
8136
8151
  },] }
8137
8152
  ];
@@ -8162,7 +8177,9 @@ BantaCommentsComponent.propDecorators = {
8162
8177
  upvoted: [{ type: Output }],
8163
8178
  reported: [{ type: Output }],
8164
8179
  selected: [{ type: Output }],
8165
- userSelected: [{ type: Output }]
8180
+ userSelected: [{ type: Output }],
8181
+ usernameSelected: [{ type: Output }],
8182
+ avatarSelected: [{ type: Output }]
8166
8183
  };
8167
8184
 
8168
8185
  class LiveCommentComponent {
@@ -8428,6 +8445,7 @@ class CommentFieldComponent {
8428
8445
  let message = {
8429
8446
  user: this.user,
8430
8447
  sentAt: Date.now(),
8448
+ url: location.href,
8431
8449
  upvotes: 0,
8432
8450
  message: text
8433
8451
  };