Skip to content

Commit

Permalink
chore: add default to userId in PowerSyncCredentials (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicGBauer authored Feb 13, 2025
1 parent 72dd7e1 commit af67832
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions Demo/PowerSyncExample/PowerSync/SupabaseConnector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,14 @@ class SupabaseConnector: PowerSyncBackendConnector {

override func fetchCredentials() async throws -> PowerSyncCredentials? {
session = try await client.auth.session

if (self.session == nil) {
throw AuthError.sessionMissing
}

let token = session!.accessToken

// userId is for debugging purposes only
return PowerSyncCredentials(endpoint: self.powerSyncEndpoint, token: token, userId: currentUserID)

return PowerSyncCredentials(endpoint: self.powerSyncEndpoint, token: token)
}

override func uploadData(database: PowerSyncDatabaseProtocol) async throws {
Expand Down
2 changes: 1 addition & 1 deletion Sources/PowerSync/PowerSyncCredentials.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct PowerSyncCredentials: Codable {
/// User ID.
public let userId: String?

public init(endpoint: String, token: String, userId: String?) {
public init(endpoint: String, token: String, userId: String? = nil) {
self.endpoint = endpoint
self.token = token
self.userId = userId
Expand Down

0 comments on commit af67832

Please sign in to comment.