@banta/sdk 4.6.0 → 4.6.1

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.
@@ -8934,9 +8934,18 @@
8934
8934
  };
8935
8935
  CommentViewComponent.prototype.sortMessages = function () {
8936
8936
  var _this = this;
8937
- this.messages.sort(function (a, b) { return (a.sentAt - b.sentAt) * (_this.newestLast ? 1 : -1); });
8938
- this.olderMessages.sort(function (a, b) { return (a.sentAt - b.sentAt) * (_this.newestLast ? 1 : -1); });
8939
- this.newMessages.sort(function (a, b) { return (a.sentAt - b.sentAt) * (_this.newestLast ? 1 : -1); });
8937
+ if (!this.source)
8938
+ return;
8939
+ var sorter;
8940
+ if (this.source.sortOrder === common$1.CommentsOrder.LIKES)
8941
+ sorter = function (a, b) { return b.likes - a.likes; };
8942
+ else if (this.source.sortOrder === common$1.CommentsOrder.NEWEST)
8943
+ sorter = function (a, b) { return (b.sentAt - a.sentAt) * (_this.newestLast ? -1 : 1); };
8944
+ else if (this.source.sortOrder === common$1.CommentsOrder.OLDEST)
8945
+ sorter = function (a, b) { return (a.sentAt - b.sentAt) * (_this.newestLast ? -1 : 1); };
8946
+ this.messages.sort(sorter);
8947
+ this.olderMessages.sort(sorter);
8948
+ this.newMessages.sort(sorter);
8940
8949
  };
8941
8950
  CommentViewComponent.prototype.messageReceived = function (message) {
8942
8951
  var _this = this;