Skip to content

Commit e155e65

Browse files
committed
fix: revert new Realtime API featuring Broadcast and Presence
1 parent 03072d1 commit e155e65

File tree

3 files changed

+11
-47
lines changed

3 files changed

+11
-47
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@supabase/functions-js": "^1.3.4",
4141
"@supabase/gotrue-js": "^1.22.17",
4242
"@supabase/postgrest-js": "^0.37.4",
43-
"@supabase/realtime-js": "^1.7.2",
43+
"@supabase/realtime-js": "^1.7.4",
4444
"@supabase/storage-js": "^1.7.2"
4545
},
4646
"devDependencies": {

src/SupabaseClient.ts

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ import { SupabaseStorageClient } from '@supabase/storage-js'
77
import { FunctionsClient } from '@supabase/functions-js'
88
import { PostgrestClient } from '@supabase/postgrest-js'
99
import { AuthChangeEvent } from '@supabase/gotrue-js'
10-
import {
11-
RealtimeClient,
12-
RealtimeSubscription,
13-
RealtimeClientOptions,
14-
RealtimeChannel,
15-
} from '@supabase/realtime-js'
10+
import { RealtimeClient, RealtimeSubscription, RealtimeClientOptions } from '@supabase/realtime-js'
1611

1712
const DEFAULT_OPTIONS = {
1813
schema: 'public',
@@ -160,20 +155,6 @@ export default class SupabaseClient {
160155
return rest.rpc<T>(fn, params, { head, count })
161156
}
162157

163-
/**
164-
* Creates a channel with Broadcast and Presence.
165-
* Activated when vsndate query param is present in the WebSocket URL.
166-
*/
167-
channel(name: string, opts: { selfBroadcast: boolean; [key: string]: any }): RealtimeChannel {
168-
const userToken = this.auth.session()?.access_token ?? this.supabaseKey
169-
170-
if (!this.realtime.isConnected()) {
171-
this.realtime.connect()
172-
}
173-
174-
return this.realtime.channel(name, { ...opts, user_token: userToken }) as RealtimeChannel
175-
}
176-
177158
/**
178159
* Closes and removes all subscriptions and returns a list of removed
179160
* subscriptions and their errors.
@@ -193,23 +174,6 @@ export default class SupabaseClient {
193174
})
194175
}
195176

196-
/**
197-
* Closes and removes a channel and returns the number of open channels.
198-
*
199-
* @param channel The channel you want to close and remove.
200-
*/
201-
async removeChannel(
202-
channel: RealtimeChannel
203-
): Promise<{ data: { openChannels: number }; error: Error | null }> {
204-
const { error } = await this._closeSubscription(channel)
205-
const allChans: RealtimeSubscription[] = this.getSubscriptions()
206-
const openChanCount = allChans.filter((chan) => chan.isJoined()).length
207-
208-
if (allChans.length === 0) await this.realtime.disconnect()
209-
210-
return { data: { openChannels: openChanCount }, error }
211-
}
212-
213177
/**
214178
* Closes and removes a subscription and returns the number of open subscriptions.
215179
*
@@ -228,7 +192,7 @@ export default class SupabaseClient {
228192
}
229193

230194
private async _closeSubscription(
231-
subscription: RealtimeSubscription | RealtimeChannel
195+
subscription: RealtimeSubscription
232196
): Promise<{ error: Error | null }> {
233197
let error = null
234198

@@ -243,7 +207,7 @@ export default class SupabaseClient {
243207
}
244208

245209
private _unsubscribeSubscription(
246-
subscription: RealtimeSubscription | RealtimeChannel
210+
subscription: RealtimeSubscription
247211
): Promise<{ error: Error | null }> {
248212
return new Promise((resolve) => {
249213
subscription

0 commit comments

Comments
 (0)