@hivegpt/hiveai-angular 0.0.266 → 0.0.268

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.
@@ -622,16 +622,18 @@
622
622
  };
623
623
  SocketService.prototype.registerUserSpecificHiveSocket = function (botId, conversation_id) {
624
624
  var _this = this;
625
- var commonNotification = "commonNotification";
625
+ var commonNotification = 'commonNotification';
626
+ var groupId = "Hive_AI_Notifs_" + botId + "_" + conversation_id;
627
+ // Remove any pre-existing listeners for commonNotification
626
628
  this.notificationSocket.removeAllListeners(commonNotification);
627
- console.log('Registering user-specific Hive socket with botId:' + botId);
628
- console.log('and conversation_id:' + conversation_id);
629
- this.notificationSocket.emit('joinData', {
630
- groupId: "Hive_AI_Notifs_" + botId + "_" + conversation_id,
631
- });
632
- this.notificationSocket
633
- .fromEvent(commonNotification)
634
- .subscribe(function (res) {
629
+ // Leave the existing group to ensure no previous socket data remains
630
+ this.notificationSocket.emit('leaveGroup', { groupId: groupId });
631
+ console.log('Registering user-specific Hive socket with botId:', botId);
632
+ console.log('and conversation_id:', conversation_id);
633
+ // Join the group again with updated botId and conversation_id
634
+ this.notificationSocket.emit('joinData', { groupId: groupId });
635
+ // Re-register for common notifications
636
+ this.notificationSocket.fromEvent(commonNotification).subscribe(function (res) {
635
637
  console.log('Received commonNotification:', res);
636
638
  _this.conversationService.sendValidatedUserData(res);
637
639
  }, function (error) {
@@ -657,7 +659,7 @@
657
659
  SocketService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SocketService_Factory() { return new SocketService(i0.ɵɵinject(ConversationService), i0.ɵɵinject(NotificationSocket)); }, token: SocketService, providedIn: "root" });
658
660
  SocketService.decorators = [
659
661
  { type: i0.Injectable, args: [{
660
- providedIn: 'root'
662
+ providedIn: 'root',
661
663
  },] }
662
664
  ];
663
665
  SocketService.ctorParameters = function () { return [
@@ -819,18 +821,22 @@
819
821
  }, 200);
820
822
  };
821
823
  ChatDrawerComponent.prototype.initializeSocket = function () {
824
+ console.log('YES INIT');
822
825
  var conversation_id = this.conversationService.getKey(this.botId);
823
826
  this.socketService.registerUserSpecificHiveSocket(this.botId, conversation_id);
824
827
  };
825
828
  ChatDrawerComponent.prototype.listenSockets = function () {
826
829
  var _this = this;
827
- if (this.eventSubscription) {
828
- this.eventSubscription.unsubscribe();
829
- }
830
+ // if (this.eventSubscription) {
831
+ // this.eventSubscription.unsubscribe();
832
+ // }
833
+ console.log('Listen Socket');
830
834
  this.eventSubscription = this.conversationService
831
835
  .getUserSpecificNotification()
832
836
  .subscribe(function (res) {
833
837
  var _a, _b, _c;
838
+ console.log('Listen Socket response');
839
+ console.log(res);
834
840
  // Check if OtherFields exists in the response
835
841
  if ((_a = res === null || res === void 0 ? void 0 : res.m) === null || _a === void 0 ? void 0 : _a.OtherFields) {
836
842
  var _e = (_b = res === null || res === void 0 ? void 0 : res.m) === null || _b === void 0 ? void 0 : _b.OtherFields, conversation_id = _e.conversation_id, bot_id = _e.bot_id, message_id_1 = _e.message_id, answer = _e.answer, web_results = _e.web_results, graphs = _e.graphs, execution_graphs = _e.execution_graphs, online_search_terms = _e.online_search_terms, suggestions = _e.suggestions;