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 {
2929
3030 factory RealtimeResponse.fromMap(Map<String , dynamic > map) {
3131 return RealtimeResponse(
32- type: map['type'] ?? '' ,
32+ type: map['type'],
3333 data: Map<String , dynamic >.from(map['data'] ?? {}),
3434 );
3535 }
Original file line number Diff line number Diff line change @@ -290,19 +290,16 @@ class Client {
290290 this.realtime.lastMessage = message;
291291 switch (message.type) {
292292 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+ }
306303 break;
307304 case 'pong':
308305 break; // Handle pong response if needed
Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ extension Realtime: WebSocketClientDelegate {
200200 if let type = json["type"] as? String {
201201 switch type {
202202 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)
204204 case TYPE_PONG: break // Handle pong response if needed
205205 default: break
206206 }
Original file line number Diff line number Diff line change @@ -485,19 +485,16 @@ class Client {
485485 }
486486 break;
487487 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+ }
501498 break;
502499 case 'pong':
503500 break; // Handle pong response if needed
You can’t perform that action at this time.
0 commit comments