@banta/sdk 4.5.1 → 4.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/banta-sdk.umd.js +113 -44
- package/bundles/banta-sdk.umd.js.map +1 -1
- package/bundles/banta-sdk.umd.min.js +1 -1
- package/bundles/banta-sdk.umd.min.js.map +1 -1
- package/esm2015/lib/chat-source.js +15 -12
- package/esm2015/lib/comments/banta-comments/banta-comments.component.js +4 -1
- package/esm2015/lib/comments/comment/comment.component.js +3 -3
- package/esm2015/lib/comments/comment-view/comment-view.component.js +59 -23
- package/fesm2015/banta-sdk.js +77 -35
- package/fesm2015/banta-sdk.js.map +1 -1
- package/lib/chat-source.d.ts +3 -1
- package/lib/comments/comment-view/comment-view.component.d.ts +2 -0
- package/package.json +1 -1
package/bundles/banta-sdk.umd.js
CHANGED
|
@@ -8421,7 +8421,7 @@
|
|
|
8421
8421
|
}
|
|
8422
8422
|
CommentComponent.prototype.ngOnInit = function () {
|
|
8423
8423
|
var _this = this;
|
|
8424
|
-
var maxTime =
|
|
8424
|
+
var maxTime = 100;
|
|
8425
8425
|
var minTime = 0;
|
|
8426
8426
|
var randomTime = minTime + Math.random() * (maxTime - minTime);
|
|
8427
8427
|
setTimeout(function () {
|
|
@@ -8577,7 +8577,7 @@
|
|
|
8577
8577
|
{ type: core.Component, args: [{
|
|
8578
8578
|
selector: 'banta-comment',
|
|
8579
8579
|
template: "\r\n<mat-menu #pointItemMenu=\"matMenu\">\r\n <button mat-menu-item (click)=\"share()\">\r\n <mat-icon>share</mat-icon>\r\n Share\r\n </button>\r\n <button *ngIf=\"!mine\" mat-menu-item (click)=\"report()\">\r\n <mat-icon>warning</mat-icon>\r\n Report\r\n </button>\r\n <button *ngIf=\"mine\" [disabled]=\"!permissions?.canEdit\" mat-menu-item (click)=\"startEdit()\">\r\n <mat-icon>edit</mat-icon>\r\n Edit\r\n </button>\r\n <button *ngIf=\"mine\" [disabled]=\"!permissions?.canDelete\" mat-menu-item (click)=\"delete()\">\r\n <mat-icon>delete</mat-icon>\r\n Delete\r\n </button>\r\n\r\n <button *ngFor=\"let menuItem of customMenuItems\" mat-menu-item (click)=\"menuItem.action(message)\">\r\n <mat-icon>{{menuItem.icon}}</mat-icon>\r\n {{menuItem.label}}\r\n </button>\r\n\r\n</mat-menu>\r\n\r\n<div class=\"message-content\">\r\n <div class=\"user\">\r\n <div class=\"user-1\">\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 <div class=\"user-identity\">\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>\r\n <div class=\"user-2\">\r\n <span class=\"user-tag\" *ngIf=\"message.user.tag\">{{message.user.tag}}</span>\r\n <banta-timestamp [value]=\"message.sentAt\"></banta-timestamp>\r\n <span class=\"spacer\"></span>\r\n </div>\r\n </div>\r\n <div class=\"content\" *ngIf=\"!editing\">\r\n <span class=\"banta-message-content\" [innerHTML]=\"message.message | markdownToHtml\"></span>\r\n <banta-attachments [attachments]=\"message.attachments\"></banta-attachments>\r\n <ul class=\"message-facts\">\r\n <li *ngIf=\"message.edits?.length > 0\">(Edited)</li>\r\n </ul>\r\n </div>\r\n <div class=\"content\" *ngIf=\"editing\" style=\"padding-bottom: 2em;\">\r\n <div>\r\n <mat-form-field floatLabel=\"always\" appearance=\"outline\" style=\"width: 100%;\">\r\n <mat-label>Edit Message</mat-label>\r\n <textarea matInput [(ngModel)]=\"editedMessage\" [maxlength]=\"maxLength\"></textarea>\r\n </mat-form-field>\r\n </div>\r\n <button mat-raised-button (click)=\"saveEdit()\">Save</button> \r\n <button mat-button (click)=\"endEditing()\">Cancel</button>\r\n </div>\r\n\r\n\r\n <div class=\"actions\">\r\n <div class=\"spacer\"></div>\r\n <div class=\"counted-action\" *ngIf=\"showReplyAction\">\r\n <button mat-button [matTooltip]=\"replyCount > 0 ? 'Replies' : 'Reply'\" matTooltipPosition=\"below\" (click)=\"select()\">\r\n <mat-icon [inline]=\"true\">comment</mat-icon>\r\n <span class=\"count-indicator\">\r\n {{replyCount > 0 ? 'Replies' : 'Reply'}}\r\n {{replyCount > 0 ? '(' + replyCount + ')' : ''}}\r\n </span>\r\n </button>\r\n </div>\r\n <div class=\"counted-action\" [class.active]=\"message.userState?.liked\">\r\n <button \r\n *ngIf=\"message.transientState?.liking\"\r\n mat-icon-button \r\n [disabled]=\"true\" \r\n [matTooltip]=\"upvoting ? 'Please wait...' : message.userState?.liked ? 'Unlike' : 'Like'\" \r\n matTooltipPosition=\"below\" \r\n >\r\n <mat-spinner [diameter]=\"15\" style=\"margin-left: 1em;\"></mat-spinner>\r\n </button>\r\n <button \r\n *ngIf=\"!message.transientState?.liking\"\r\n mat-button \r\n [matTooltip]=\"permissions?.canLike ? upvoting ? 'Please wait...' : 'Like' : permissions?.canLikeErrorMessage\" \r\n matTooltipPosition=\"below\" \r\n (click)=\"message.userState?.liked ? unlike() : like()\" \r\n >\r\n <mat-icon [inline]=\"true\">thumb_up</mat-icon>\r\n <span class=\"count-indicator\" *ngIf=\"message.likes > 0\">\r\n {{message.likes}}\r\n </span>\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",
|
|
8580
|
-
styles: ["@-webkit-keyframes comment-appear{0%{transform:translate(
|
|
8580
|
+
styles: ["@-webkit-keyframes comment-appear{0%{transform:translate(6em)}to{transform:translate(0)}}@keyframes comment-appear{0%{transform:translate(6em)}to{transform:translate(0)}}:host{display:flex;flex-direction:column;position:relative;padding:.5em;visibility:hidden}:host.new{visibility:visible;-webkit-animation-name:comment-appear;animation-name:comment-appear;-webkit-animation-duration:.25s;animation-duration:.25s;-webkit-animation-fill-mode:both;animation-fill-mode:both}:host.highlighted{background:#00223a;outline:2px solid #003277}:host.visible{visibility:visible}:host:hover{background:#eee}:host .message-content .content{margin-left:60px;margin-right:.5em}:host .message-content .attachments-row{margin-top:15px;display:flex;gap:10px}:host .message-content .attachments-row img{border-radius:10px;width:300px;max-width:100%;max-height:20em;-o-object-fit:cover;object-fit:cover}:host.abbreviated .message-content .content{text-overflow:ellipsis;overflow-y:hidden}:host .actions{display:flex;padding-right:10px;margin-left:60px;align-items:center}:host .actions button,banta-timestamp{color:#666;flex-shrink:0}banta-timestamp{font-size:10pt;margin-left:1em;text-align:right}.user{position:relative;margin:1em 0 0;display:flex;align-items:center;flex-wrap:wrap}.user .user-1,.user .user-2{display:flex;flex-wrap:nowrap;align-items:center;min-width:0}.user .user-2{margin:1em 0}.user .user-identity{display:flex;flex-direction:column;min-width:0}.user .display-name,.user .username{z-index:1;position:relative;padding:0 0 0 1em;font-size:10pt;color:#000;margin:0 auto 0 0;display:block;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;max-width:100%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex-shrink:1;flex-grow:0;min-width:0}.user .display-name.username.username.username,.user .username.username.username.username{color:#666}.avatar{height:48px;width:48px;background-position:50%;background-size:cover;background-color:#333;border-radius:100%;flex-shrink:0;flex-grow:0}.counted-action{display:flex;align-items:center}.counted-action.active .count-indicator,.counted-action.active button{color:#00a5ff}.counted-action button .count-indicator{margin-left:.5em}.count-indicator{font-size:9pt;padding:0 0 0 3px;color:#666}:host-context(.mat-dark-theme) .count-indicator{border-color:#333}:host-context(.mat-dark-theme):hover{background:#060606}.user-tag,:host-context(.mat-dark-theme) .user .display-name,:host-context(.mat-dark-theme) .user .username{color:#fff}.user-tag{text-transform:uppercase;font-size:12px;border:1px solid #b27373;background:#7a412b;padding:3px 5px;margin:0 .5em 0 1em;border-radius:3px}.spacer{flex-shrink:1;flex-grow:1}ul.message-facts{margin:0;padding:0;color:#666}ul.message-facts li{list-style-type:none;border-left:1px solid #666;font-size:10pt;padding-left:.5em;margin-left:.5em;margin-top:.5em}ul.message-facts li:first-child{border-left:1px solid transparent;margin-left:0;padding-left:0}@media (max-width:400px){.avatar{height:32px;width:32px}:host .actions{margin-left:0;margin-top:.5em}:host .message-content .content{margin-left:44px;margin-right:.5em}}:host-context(.banta-mobile) .avatar{height:32px;width:32px}:host-context(.banta-mobile) :host .actions{margin-left:0;margin-top:.5em}:host-context(.banta-mobile) :host .message-content .content{margin-left:44px;margin-right:.5em}.card-attachment a{display:flex;align-items:flex-start;gap:1em;width:100%;border:1px solid #666;border-radius:4px;padding:1em;box-sizing:border-box;background-color:#191919}.card-attachment a img{width:300px;aspect-ratio:16/9;-o-object-fit:cover;object-fit:cover;border-radius:10px}.card-attachment a h1{margin:0;font-size:30px}"]
|
|
8581
8581
|
},] }
|
|
8582
8582
|
];
|
|
8583
8583
|
CommentComponent.propDecorators = {
|
|
@@ -8758,13 +8758,14 @@
|
|
|
8758
8758
|
CommentViewComponent.prototype.getInitialMessages = function () {
|
|
8759
8759
|
return __awaiter(this, void 0, void 0, function () {
|
|
8760
8760
|
var messages;
|
|
8761
|
-
return __generator(this, function (
|
|
8762
|
-
switch (
|
|
8761
|
+
return __generator(this, function (_c) {
|
|
8762
|
+
switch (_c.label) {
|
|
8763
8763
|
case 0: return [4 /*yield*/, this._source.getExistingMessages()];
|
|
8764
8764
|
case 1:
|
|
8765
|
-
messages = (
|
|
8765
|
+
messages = (_c.sent());
|
|
8766
8766
|
messages.forEach(function (m) { var _a; return (_a = m.transientState) !== null && _a !== void 0 ? _a : (m.transientState = {}); });
|
|
8767
|
-
this.messages = messages;
|
|
8767
|
+
this.messages = this.newestLast ? messages.slice().reverse() : messages;
|
|
8768
|
+
this.sortMessages();
|
|
8768
8769
|
return [2 /*return*/];
|
|
8769
8770
|
}
|
|
8770
8771
|
});
|
|
@@ -8775,14 +8776,18 @@
|
|
|
8775
8776
|
};
|
|
8776
8777
|
CommentViewComponent.prototype.showNew = function () {
|
|
8777
8778
|
return __awaiter(this, void 0, void 0, function () {
|
|
8778
|
-
var overflow;
|
|
8779
|
-
return __generator(this, function (
|
|
8780
|
-
|
|
8781
|
-
|
|
8779
|
+
var naturalOrder, overflow;
|
|
8780
|
+
return __generator(this, function (_c) {
|
|
8781
|
+
naturalOrder = common$1.CommentsOrder.NEWEST;
|
|
8782
|
+
if (this.source && this.source.sortOrder !== naturalOrder) {
|
|
8783
|
+
this.sortOrderChanged.next(naturalOrder);
|
|
8782
8784
|
return [2 /*return*/];
|
|
8783
8785
|
}
|
|
8784
8786
|
this.isViewingMore = false;
|
|
8785
|
-
|
|
8787
|
+
if (this.newestLast)
|
|
8788
|
+
this.messages = this.messages.concat(this.newMessages.splice(0, this.newMessages.length));
|
|
8789
|
+
else
|
|
8790
|
+
this.messages = this.newMessages.splice(0, this.newMessages.length).concat(this.messages);
|
|
8786
8791
|
overflow = this.messages.splice(this.maxVisibleMessages, this.messages.length);
|
|
8787
8792
|
this.olderMessages = overflow.concat(this.olderMessages);
|
|
8788
8793
|
this.olderMessages.splice(this.maxMessages - this.maxVisibleMessages, this.olderMessages.length);
|
|
@@ -8791,38 +8796,45 @@
|
|
|
8791
8796
|
});
|
|
8792
8797
|
};
|
|
8793
8798
|
CommentViewComponent.prototype.showMore = function () {
|
|
8799
|
+
var _a, _b;
|
|
8794
8800
|
return __awaiter(this, void 0, void 0, function () {
|
|
8795
8801
|
var nextPageSize, lastMessage, messages;
|
|
8796
|
-
return __generator(this, function (
|
|
8797
|
-
switch (
|
|
8802
|
+
return __generator(this, function (_c) {
|
|
8803
|
+
switch (_c.label) {
|
|
8798
8804
|
case 0:
|
|
8799
8805
|
this.isViewingMore = true;
|
|
8800
|
-
if (
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
case 1:
|
|
8806
|
+
if (this.olderMessages.length > 0) {
|
|
8807
|
+
this.isLoadingMore = false;
|
|
8808
|
+
this.messages = this.messages.concat(this.olderMessages.splice(0, 50));
|
|
8809
|
+
}
|
|
8805
8810
|
this.isLoadingMore = true;
|
|
8806
8811
|
nextPageSize = 20;
|
|
8807
|
-
|
|
8808
|
-
|
|
8812
|
+
if (this.newestLast) {
|
|
8813
|
+
lastMessage = (_a = this.olderMessages[0]) !== null && _a !== void 0 ? _a : this.messages[0];
|
|
8814
|
+
}
|
|
8815
|
+
else {
|
|
8816
|
+
lastMessage = (_b = this.olderMessages[this.olderMessages.length - 1]) !== null && _b !== void 0 ? _b : this.messages[this.messages.length - 1];
|
|
8817
|
+
}
|
|
8818
|
+
console.dir(lastMessage);
|
|
8809
8819
|
if (!lastMessage) {
|
|
8810
8820
|
this.isLoadingMore = false;
|
|
8811
8821
|
this.hasMore = false;
|
|
8812
8822
|
return [2 /*return*/];
|
|
8813
8823
|
}
|
|
8814
8824
|
return [4 /*yield*/, this.source.loadAfter(lastMessage, nextPageSize)];
|
|
8815
|
-
case
|
|
8816
|
-
messages =
|
|
8825
|
+
case 1:
|
|
8826
|
+
messages = _c.sent();
|
|
8817
8827
|
messages.forEach(function (m) { var _a; return (_a = m.transientState) !== null && _a !== void 0 ? _a : (m.transientState = {}); });
|
|
8818
|
-
|
|
8828
|
+
if (this.newestLast)
|
|
8829
|
+
this.messages = messages.concat(this.messages);
|
|
8830
|
+
else
|
|
8831
|
+
this.messages = this.messages.concat(messages);
|
|
8819
8832
|
this.isLoadingMore = false;
|
|
8820
8833
|
if (messages.length === 0) {
|
|
8821
8834
|
console.log("Reached the end of the list.");
|
|
8822
8835
|
this.hasMore = false;
|
|
8823
8836
|
}
|
|
8824
|
-
|
|
8825
|
-
case 3: return [2 /*return*/];
|
|
8837
|
+
return [2 /*return*/];
|
|
8826
8838
|
}
|
|
8827
8839
|
});
|
|
8828
8840
|
});
|
|
@@ -8833,11 +8845,11 @@
|
|
|
8833
8845
|
(_a = message.transientState) !== null && _a !== void 0 ? _a : (message.transientState = {});
|
|
8834
8846
|
var destination = this.messages;
|
|
8835
8847
|
var bucket = this.olderMessages;
|
|
8848
|
+
var newestLast = this.newestLast;
|
|
8836
8849
|
if (this.isViewingMore) {
|
|
8837
8850
|
destination = this.newMessages;
|
|
8838
8851
|
bucket = null;
|
|
8839
8852
|
}
|
|
8840
|
-
var newestLast = this.newestLast;
|
|
8841
8853
|
if (newestLast) {
|
|
8842
8854
|
destination.push(message);
|
|
8843
8855
|
var overflow = destination.splice(this.maxVisibleMessages, destination.length);
|
|
@@ -8850,6 +8862,51 @@
|
|
|
8850
8862
|
}
|
|
8851
8863
|
if ((bucket === null || bucket === void 0 ? void 0 : bucket.length) > 0)
|
|
8852
8864
|
this.hasMore = true;
|
|
8865
|
+
message.pagingCursor = String(this.incrementPagingCursors());
|
|
8866
|
+
this.sortMessages();
|
|
8867
|
+
};
|
|
8868
|
+
CommentViewComponent.prototype.incrementPagingCursors = function () {
|
|
8869
|
+
var e_1, _c, e_2, _d;
|
|
8870
|
+
if (this.source.sortOrder !== common$1.CommentsOrder.NEWEST)
|
|
8871
|
+
return;
|
|
8872
|
+
var maxPagingCursor = 0;
|
|
8873
|
+
try {
|
|
8874
|
+
for (var _e = __values([this.messages, this.olderMessages, this.newMessages]), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
8875
|
+
var group = _f.value;
|
|
8876
|
+
try {
|
|
8877
|
+
for (var group_1 = (e_2 = void 0, __values(group)), group_1_1 = group_1.next(); !group_1_1.done; group_1_1 = group_1.next()) {
|
|
8878
|
+
var message = group_1_1.value;
|
|
8879
|
+
if (message.pagingCursor) {
|
|
8880
|
+
var pagingCursor = Number(message.pagingCursor) + 1;
|
|
8881
|
+
if (pagingCursor > maxPagingCursor)
|
|
8882
|
+
maxPagingCursor = pagingCursor;
|
|
8883
|
+
message.pagingCursor = String(pagingCursor);
|
|
8884
|
+
}
|
|
8885
|
+
}
|
|
8886
|
+
}
|
|
8887
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
8888
|
+
finally {
|
|
8889
|
+
try {
|
|
8890
|
+
if (group_1_1 && !group_1_1.done && (_d = group_1.return)) _d.call(group_1);
|
|
8891
|
+
}
|
|
8892
|
+
finally { if (e_2) throw e_2.error; }
|
|
8893
|
+
}
|
|
8894
|
+
}
|
|
8895
|
+
}
|
|
8896
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
8897
|
+
finally {
|
|
8898
|
+
try {
|
|
8899
|
+
if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
|
|
8900
|
+
}
|
|
8901
|
+
finally { if (e_1) throw e_1.error; }
|
|
8902
|
+
}
|
|
8903
|
+
return maxPagingCursor;
|
|
8904
|
+
};
|
|
8905
|
+
CommentViewComponent.prototype.sortMessages = function () {
|
|
8906
|
+
var _this = this;
|
|
8907
|
+
this.messages.sort(function (a, b) { return (a.sentAt - b.sentAt) * (_this.newestLast ? 1 : -1); });
|
|
8908
|
+
this.olderMessages.sort(function (a, b) { return (a.sentAt - b.sentAt) * (_this.newestLast ? 1 : -1); });
|
|
8909
|
+
this.newMessages.sort(function (a, b) { return (a.sentAt - b.sentAt) * (_this.newestLast ? 1 : -1); });
|
|
8853
8910
|
};
|
|
8854
8911
|
CommentViewComponent.prototype.messageReceived = function (message) {
|
|
8855
8912
|
var _this = this;
|
|
@@ -8889,7 +8946,7 @@
|
|
|
8889
8946
|
CommentViewComponent.decorators = [
|
|
8890
8947
|
{ type: core.Component, args: [{
|
|
8891
8948
|
selector: 'banta-comment-view',
|
|
8892
|
-
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 || customSortEnabled\" 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 <ng-container *ngFor=\"let message of messages; trackBy: messageIdentity\">\r\n <banta-comment\r\n *ngIf=\"!message.hidden\"\r\n class=\"abbreviated\"\r\n \r\n [customMenuItems]=\"customMenuItems\"\r\n [message]=\"message\"\r\n [mine]=\"currentUser?.id === message.user?.id\"\r\n [permissions]=\"source?.permissions\"\r\n [showReplyAction]=\"allowReplies\"\r\n [editing]=\"message.transientState.editing\"\r\n [genericAvatarUrl]=\"genericAvatarUrl\"\r\n (click)=\"isViewingMore = true\"\r\n (editStarted)=\"startEditing(message)\"\r\n (deleted)=\"deleteMessage(message)\"\r\n (editEnded)=\"message.transientState.editing = false\"\r\n (edited)=\"saveEdit(message, $event)\"\r\n (userSelected)=\"selectMessageUser(message)\"\r\n (avatarSelected)=\"selectAvatar($event)\"\r\n (usernameSelected)=\"selectUsername($event)\"\r\n (liked)=\"likeMessage(message)\"\r\n (unliked)=\"unlikeMessage(message)\"\r\n (reported)=\"reportMessage(message)\"\r\n (selected)=\"selectMessage(message)\"\r\n (shared)=\"sharedMessage($event)\"\r\n ></banta-comment>\r\n <div class=\"inline-replies-container\" *ngIf=\"selectedMessage === message\">\r\n <ng-content select=\".inline-replies\"></ng-content>\r\n </div>\r\n </ng-container>\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]):not(.inline-replies)\"></ng-content>\r\n</div>\r\n",
|
|
8949
|
+
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]=\"!newestLast && (isViewingMore || customSortEnabled)\" 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 <a mat-button class=\"nav\" [class.visible]=\"newestLast && hasMore && !isLoadingMore\" href=\"javascript:;\" (click)=\"showMore()\">Show earlier</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 <ng-container *ngFor=\"let message of messages; trackBy: messageIdentity\">\r\n <banta-comment\r\n *ngIf=\"!message.hidden\"\r\n class=\"abbreviated\"\r\n \r\n [customMenuItems]=\"customMenuItems\"\r\n [message]=\"message\"\r\n [mine]=\"currentUser?.id === message.user?.id\"\r\n [permissions]=\"source?.permissions\"\r\n [showReplyAction]=\"allowReplies\"\r\n [editing]=\"message.transientState.editing\"\r\n [genericAvatarUrl]=\"genericAvatarUrl\"\r\n (click)=\"isViewingMore = true\"\r\n (editStarted)=\"startEditing(message)\"\r\n (deleted)=\"deleteMessage(message)\"\r\n (editEnded)=\"message.transientState.editing = false\"\r\n (edited)=\"saveEdit(message, $event)\"\r\n (userSelected)=\"selectMessageUser(message)\"\r\n (avatarSelected)=\"selectAvatar($event)\"\r\n (usernameSelected)=\"selectUsername($event)\"\r\n (liked)=\"likeMessage(message)\"\r\n (unliked)=\"unlikeMessage(message)\"\r\n (reported)=\"reportMessage(message)\"\r\n (selected)=\"selectMessage(message)\"\r\n (shared)=\"sharedMessage($event)\"\r\n ></banta-comment>\r\n <div class=\"inline-replies-container\" *ngIf=\"selectedMessage === message\">\r\n <ng-content select=\".inline-replies\"></ng-content>\r\n </div>\r\n </ng-container>\r\n\r\n <a mat-button class=\"nav\" [class.visible]=\"newestLast && (isViewingMore || customSortEnabled)\" href=\"javascript:;\" (click)=\"showNew()\">\r\n <mat-icon>file_download</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 <a mat-button class=\"nav\" [class.visible]=\"!newestLast && 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]):not(.inline-replies)\"></ng-content>\r\n</div>\r\n",
|
|
8893
8950
|
styles: [":host{flex-grow:1;display:flex;flex-direction:column;opacity:1;transition:opacity .2s ease-in}.message-container{flex-grow:1;overflow-x:hidden;color:#111;background:#fff;padding:.5em 1em 3em .5em;opacity:1;transition:opacity .5s ease-in-out;position:relative}.message-container.no-scroll{height:auto;overflow-y:visible}.message-container.faded{opacity:.25}.message-container .overlay{position:absolute;top:0;left:0;right:0;bottom:0;z-index:10}:host.fixed-height .message-container{overflow-y:auto}:host-context(.mat-dark-theme) .message-container{color:#fff;background:#111}.empty-state{text-align:center;margin:3em;color:#666}:host-context(.mat-dark-theme) .empty-state{color:#666}a.nav{position:absolute;right:.5em;z-index:10;text-align:center;opacity:0;transition:opacity .4s ease-in-out;pointer-events:none;border-radius:2em;background:#222}a.nav.visible{opacity:1;pointer-events:auto}.loading-more{padding:2em;text-align:center;margin:0 auto;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}@media (max-width:400px){.message-container{padding:0 0 3em}}"]
|
|
8894
8951
|
},] }
|
|
8895
8952
|
];
|
|
@@ -9598,6 +9655,7 @@
|
|
|
9598
9655
|
});
|
|
9599
9656
|
};
|
|
9600
9657
|
BantaCommentsComponent.prototype.deleteMessage = function (message) {
|
|
9658
|
+
var _a;
|
|
9601
9659
|
return __awaiter(this, void 0, void 0, function () {
|
|
9602
9660
|
var e_6;
|
|
9603
9661
|
return __generator(this, function (_d) {
|
|
@@ -9617,6 +9675,8 @@
|
|
|
9617
9675
|
return [4 /*yield*/, this.source.deleteMessage(message.id)];
|
|
9618
9676
|
case 4:
|
|
9619
9677
|
_d.sent();
|
|
9678
|
+
if (((_a = this.selectedMessage) === null || _a === void 0 ? void 0 : _a.id) === message.id)
|
|
9679
|
+
this.unselectMessage();
|
|
9620
9680
|
return [3 /*break*/, 6];
|
|
9621
9681
|
case 5:
|
|
9622
9682
|
e_6 = _d.sent();
|
|
@@ -10638,23 +10698,27 @@
|
|
|
10638
10698
|
});
|
|
10639
10699
|
});
|
|
10640
10700
|
};
|
|
10701
|
+
ChatSource.prototype.mapOrUpdateMessages = function (messages) {
|
|
10702
|
+
var _this = this;
|
|
10703
|
+
return messages.map(function (message) { return _this.mapOrUpdateMessage(message); });
|
|
10704
|
+
};
|
|
10705
|
+
ChatSource.prototype.mapOrUpdateMessage = function (message) {
|
|
10706
|
+
var existingMessage = this.messageMap.get(message.id);
|
|
10707
|
+
if (existingMessage)
|
|
10708
|
+
message = Object.assign(existingMessage, message);
|
|
10709
|
+
else
|
|
10710
|
+
this.messageMap.set(message.id, message);
|
|
10711
|
+
return message;
|
|
10712
|
+
};
|
|
10641
10713
|
ChatSource.prototype.getExistingMessages = function () {
|
|
10642
10714
|
return __awaiter(this, void 0, void 0, function () {
|
|
10643
10715
|
var messages;
|
|
10644
|
-
var _this = this;
|
|
10645
10716
|
return __generator(this, function (_b) {
|
|
10646
10717
|
switch (_b.label) {
|
|
10647
10718
|
case 0: return [4 /*yield*/, this.peer.getExistingMessages()];
|
|
10648
10719
|
case 1:
|
|
10649
10720
|
messages = _b.sent();
|
|
10650
|
-
messages =
|
|
10651
|
-
var existingMessage = _this.messageMap.get(message.id);
|
|
10652
|
-
if (existingMessage)
|
|
10653
|
-
message = Object.assign(existingMessage, message);
|
|
10654
|
-
else
|
|
10655
|
-
_this.messageMap.set(message.id, message);
|
|
10656
|
-
return message;
|
|
10657
|
-
});
|
|
10721
|
+
messages = this.mapOrUpdateMessages(messages);
|
|
10658
10722
|
return [2 /*return*/, messages];
|
|
10659
10723
|
}
|
|
10660
10724
|
});
|
|
@@ -10737,8 +10801,7 @@
|
|
|
10737
10801
|
};
|
|
10738
10802
|
ChatSource.prototype.onChatMessage = function (message) {
|
|
10739
10803
|
if (this.messageMap.has(message.id)) {
|
|
10740
|
-
|
|
10741
|
-
this._messageUpdated.next(message);
|
|
10804
|
+
return this.mapOrUpdateMessage(message);
|
|
10742
10805
|
}
|
|
10743
10806
|
else if (!message.hidden) {
|
|
10744
10807
|
// Only process non-hidden messages through here.
|
|
@@ -10778,12 +10841,18 @@
|
|
|
10778
10841
|
};
|
|
10779
10842
|
ChatSource.prototype.loadAfter = function (message, count) {
|
|
10780
10843
|
return __awaiter(this, void 0, void 0, function () {
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10844
|
+
var _b;
|
|
10845
|
+
return __generator(this, function (_c) {
|
|
10846
|
+
switch (_c.label) {
|
|
10847
|
+
case 0:
|
|
10848
|
+
if (!message)
|
|
10849
|
+
return [2 /*return*/];
|
|
10850
|
+
if (!message.pagingCursor)
|
|
10851
|
+
return [2 /*return*/, []];
|
|
10852
|
+
_b = this.mapOrUpdateMessages;
|
|
10853
|
+
return [4 /*yield*/, this.peer.loadAfter(Number(message.pagingCursor), count)];
|
|
10854
|
+
case 1: return [2 /*return*/, _b.apply(this, [_c.sent()])];
|
|
10855
|
+
}
|
|
10787
10856
|
});
|
|
10788
10857
|
});
|
|
10789
10858
|
};
|