File tree Expand file tree Collapse file tree 4 files changed +22
-28
lines changed Expand file tree Collapse file tree 4 files changed +22
-28
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class RealtimeResponse {
29
29
30
30
factory RealtimeResponse.fromMap(Map<String , dynamic > map) {
31
31
return RealtimeResponse(
32
- type: map['type'] ?? '' ,
32
+ type: map['type'],
33
33
data: Map<String , dynamic >.from(map['data'] ?? {}),
34
34
);
35
35
}
Original file line number Diff line number Diff line change @@ -290,19 +290,16 @@ class Client {
290
290
this.realtime.lastMessage = message;
291
291
switch (message.type) {
292
292
case 'event':
293
- if(!message.data) return;
294
-
295
- const data = message.data as RealtimeResponseEvent<unknown >;
296
- if (!data?.channels) return;
297
-
298
- const isSubscribed = data.channels.some(channel => this.realtime.channels.has(channel));
299
- if (!isSubscribed) return;
300
-
301
- this.realtime.subscriptions.forEach(subscription => {
302
- if (data.channels.some(channel => subscription.channels.includes(channel))) {
303
- setTimeout(() => subscription.callback(data));
304
- }
305
- });
293
+ let data = <RealtimeResponseEvent <unknown >>message.data;
294
+ if (data?.channels) {
295
+ const isSubscribed = data.channels.some(channel => this.realtime.channels.has(channel));
296
+ if (!isSubscribed) return;
297
+ this.realtime.subscriptions.forEach(subscription => {
298
+ if (data.channels.some(channel => subscription.channels.includes(channel))) {
299
+ setTimeout(() => subscription.callback(data));
300
+ }
301
+ })
302
+ }
306
303
break;
307
304
case 'pong':
308
305
break; // Handle pong response if needed
Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ extension Realtime: WebSocketClientDelegate {
200
200
if let type = json["type"] as? String {
201
201
switch type {
202
202
case TYPE_ERROR: try! handleResponseError(from: json)
203
- case TYPE_EVENT: if json["data"] != nil { handleResponseEvent(from: json)}
203
+ case TYPE_EVENT: handleResponseEvent(from: json)
204
204
case TYPE_PONG: break // Handle pong response if needed
205
205
default: break
206
206
}
Original file line number Diff line number Diff line change @@ -485,19 +485,16 @@ class Client {
485
485
}
486
486
break;
487
487
case 'event':
488
- if (!message.data) return;
489
-
490
- const data = message.data as RealtimeResponseEvent<unknown >;
491
- if (!data?.channels) return;
492
-
493
- const isSubscribed = data.channels.some(channel => this.realtime.channels.has(channel));
494
- if (!isSubscribed) return;
495
-
496
- this.realtime.subscriptions.forEach(subscription => {
497
- if (data.channels.some(channel => subscription.channels.includes(channel))) {
498
- setTimeout(() => subscription.callback(data));
499
- }
500
- });
488
+ let data = <RealtimeResponseEvent <unknown >>message.data;
489
+ if (data?.channels) {
490
+ const isSubscribed = data.channels.some(channel => this.realtime.channels.has(channel));
491
+ if (!isSubscribed) return;
492
+ this.realtime.subscriptions.forEach(subscription => {
493
+ if (data.channels.some(channel => subscription.channels.includes(channel))) {
494
+ setTimeout(() => subscription.callback(data));
495
+ }
496
+ })
497
+ }
501
498
break;
502
499
case 'pong':
503
500
break; // Handle pong response if needed
You can’t perform that action at this time.
0 commit comments