http-request-manager 18.7.0 → 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) {
|
|
@@ -3102,12 +3108,19 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
3102
3108
|
console.log(`ℹ️ Info: ${message.message}`);
|
|
3103
3109
|
break;
|
|
3104
3110
|
case 'stateMangerMessage':
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3111
|
+
// Compare sender's session ID with current user's ID
|
|
3112
|
+
// message.data.sessionId is an object with 'id' property from server
|
|
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);
|
|
3115
|
+
if (stateManagerSenderId !== this.user.value?.id) {
|
|
3116
|
+
console.log('💬 State Manager Message:', message.data);
|
|
3117
|
+
console.log('📥 Fetching record with path:', message.data.content.path, 'method:', message.data.content.method);
|
|
3108
3118
|
this.userAction.next(message.data);
|
|
3109
3119
|
this.fetchRecord(RequestOptions.adapt({ path: message.data.content.path }), message.data.content.method);
|
|
3110
3120
|
}
|
|
3121
|
+
else {
|
|
3122
|
+
console.log('⏭️ Skipping own message');
|
|
3123
|
+
}
|
|
3111
3124
|
break;
|
|
3112
3125
|
case 'channelMessage':
|
|
3113
3126
|
// Handle channel-based messages (from sendChannelMessage)
|
|
@@ -3337,19 +3350,27 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
3337
3350
|
return fetchFromAPI();
|
|
3338
3351
|
})));
|
|
3339
3352
|
// FETCH RECORD
|
|
3340
|
-
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) => {
|
|
3341
3354
|
this.streamedResponse = [];
|
|
3342
3355
|
const requestOptions = this.updateRequestOptions(options?.headers);
|
|
3356
|
+
console.log('🌐 Making GET request to path:', options?.path);
|
|
3343
3357
|
return this.httpManagerService.getRequest(requestOptions, options?.path)
|
|
3344
3358
|
.pipe(tap((data) => {
|
|
3359
|
+
console.log('📦 fetchRecord received data:', data);
|
|
3345
3360
|
data = (!data) ? (this.dataType === DataType.ARRAY) ? [] : {} : data;
|
|
3346
3361
|
const id = options.path?.length ? options.path[options.path.length - 1] : null;
|
|
3347
|
-
if (method === 'DELETE')
|
|
3362
|
+
if (method === 'DELETE') {
|
|
3363
|
+
console.log('🗑️ Deleting record with id:', id);
|
|
3348
3364
|
this.deleteData$({ id });
|
|
3349
|
-
|
|
3365
|
+
}
|
|
3366
|
+
if (method === 'UPDATE') {
|
|
3367
|
+
console.log('✏️ Updating record:', data);
|
|
3350
3368
|
this.updateData$(data);
|
|
3351
|
-
|
|
3369
|
+
}
|
|
3370
|
+
if (method === 'CREATE') {
|
|
3371
|
+
console.log('➕ Adding record:', data);
|
|
3352
3372
|
this.addData$(data);
|
|
3373
|
+
}
|
|
3353
3374
|
}), concatMap((data) => {
|
|
3354
3375
|
if (this.hasDatabase && this.databaseOptions?.table) {
|
|
3355
3376
|
const id = options.path?.length ? options.path[options.path.length - 1] : null;
|