http-request-manager 18.7.1 → 18.7.2
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.
|
@@ -789,7 +789,9 @@ class WebsocketService {
|
|
|
789
789
|
})();
|
|
790
790
|
}
|
|
791
791
|
sendSubscribe(channelName, user) {
|
|
792
|
-
if (
|
|
792
|
+
// Check if already subscribed to THIS specific channel (not just any channel)
|
|
793
|
+
const alreadySubscribed = this.subscribedChannels.value.has(channelName);
|
|
794
|
+
if (this.socket?.readyState === WebSocket.OPEN && !alreadySubscribed) {
|
|
793
795
|
const message = {
|
|
794
796
|
type: 'subscribe',
|
|
795
797
|
subscribedChannel: channelName,
|
|
@@ -799,11 +801,15 @@ class WebsocketService {
|
|
|
799
801
|
}
|
|
800
802
|
};
|
|
801
803
|
this.socket.send(JSON.stringify(message));
|
|
802
|
-
|
|
804
|
+
// Track this channel as subscribed
|
|
805
|
+
const current = new Set(this.subscribedChannels.value);
|
|
806
|
+
current.add(channelName);
|
|
807
|
+
this.subscribedChannels.next(current);
|
|
808
|
+
this.isSubscribed = true; // Keep for backward compatibility
|
|
803
809
|
console.log(`[CLIENT] Sent initial subscription to: ${channelName}`);
|
|
804
810
|
}
|
|
805
811
|
else {
|
|
806
|
-
console.warn(`[CLIENT] Subscription prevented. Open: ${this.socket?.readyState === WebSocket.OPEN},
|
|
812
|
+
console.warn(`[CLIENT] Subscription prevented. Open: ${this.socket?.readyState === WebSocket.OPEN}, Already subscribed to ${channelName}: ${alreadySubscribed}`);
|
|
807
813
|
}
|
|
808
814
|
}
|
|
809
815
|
connect(options, jwtToken) {
|
|
@@ -3105,11 +3111,16 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
3105
3111
|
// Compare sender's session ID with current user's ID
|
|
3106
3112
|
// message.data.sessionId is an object with 'id' property from server
|
|
3107
3113
|
const stateManagerSenderId = message.data.sessionId?.id || message.data.sessionId;
|
|
3114
|
+
console.log('🔍 State Manager: Sender ID:', stateManagerSenderId, 'Current User ID:', this.user.value?.id);
|
|
3108
3115
|
if (stateManagerSenderId !== this.user.value?.id) {
|
|
3109
3116
|
console.log('💬 State Manager Message:', message.data);
|
|
3117
|
+
console.log('📥 Fetching record with path:', message.data.content.path, 'method:', message.data.content.method);
|
|
3110
3118
|
this.userAction.next(message.data);
|
|
3111
3119
|
this.fetchRecord(RequestOptions.adapt({ path: message.data.content.path }), message.data.content.method);
|
|
3112
3120
|
}
|
|
3121
|
+
else {
|
|
3122
|
+
console.log('⏭️ Skipping own message');
|
|
3123
|
+
}
|
|
3113
3124
|
break;
|
|
3114
3125
|
case 'channelMessage':
|
|
3115
3126
|
// Handle channel-based messages (from sendChannelMessage)
|
|
@@ -3339,19 +3350,27 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
3339
3350
|
return fetchFromAPI();
|
|
3340
3351
|
})));
|
|
3341
3352
|
// FETCH RECORD
|
|
3342
|
-
this.fetchRecord = (options, method) => this.effect(() => of(RequestOptions.adapt(options)).pipe(switchMap((options) => {
|
|
3353
|
+
this.fetchRecord = (options, method) => this.effect(() => of(RequestOptions.adapt(options)).pipe(tap(() => console.log('🔄 fetchRecord effect triggered with path:', options?.path, 'method:', method)), switchMap((options) => {
|
|
3343
3354
|
this.streamedResponse = [];
|
|
3344
3355
|
const requestOptions = this.updateRequestOptions(options?.headers);
|
|
3356
|
+
console.log('🌐 Making GET request to path:', options?.path);
|
|
3345
3357
|
return this.httpManagerService.getRequest(requestOptions, options?.path)
|
|
3346
3358
|
.pipe(tap((data) => {
|
|
3359
|
+
console.log('📦 fetchRecord received data:', data);
|
|
3347
3360
|
data = (!data) ? (this.dataType === DataType.ARRAY) ? [] : {} : data;
|
|
3348
3361
|
const id = options.path?.length ? options.path[options.path.length - 1] : null;
|
|
3349
|
-
if (method === 'DELETE')
|
|
3362
|
+
if (method === 'DELETE') {
|
|
3363
|
+
console.log('🗑️ Deleting record with id:', id);
|
|
3350
3364
|
this.deleteData$({ id });
|
|
3351
|
-
|
|
3365
|
+
}
|
|
3366
|
+
if (method === 'UPDATE') {
|
|
3367
|
+
console.log('✏️ Updating record:', data);
|
|
3352
3368
|
this.updateData$(data);
|
|
3353
|
-
|
|
3369
|
+
}
|
|
3370
|
+
if (method === 'CREATE') {
|
|
3371
|
+
console.log('➕ Adding record:', data);
|
|
3354
3372
|
this.addData$(data);
|
|
3373
|
+
}
|
|
3355
3374
|
}), concatMap((data) => {
|
|
3356
3375
|
if (this.hasDatabase && this.databaseOptions?.table) {
|
|
3357
3376
|
const id = options.path?.length ? options.path[options.path.length - 1] : null;
|