Skip to content

Commit

Permalink
only send token if changed
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Feb 7, 2025
1 parent 778cd26 commit 898619c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/Realtime/RealtimeClientV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,14 @@ public final class RealtimeClientV2: Sendable {
/// On callback used, it will set the value of the token internal to the client.
/// - Parameter token: A JWT string to override the token set on the client.
public func setAuth(_ token: String? = nil) async {
var token = token
var tokenToSend = token

if token == nil {
token = try? await options.accessToken?()
if tokenToSend == nil {
tokenToSend = try? await options.accessToken?()
}

if token == nil {
token = mutableState.accessToken
guard tokenToSend != mutableState.accessToken else {
return
}

mutableState.withValue { [token] in
Expand Down

0 comments on commit 898619c

Please sign in to comment.