Skip to content

Commit 3751208

Browse files
author
DominicGBauer
committed
chore: update supabase
1 parent c9582ed commit 3751208

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

connectors/supabase/src/commonMain/kotlin/com/powersync/connector/supabase/SupabaseConnector.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.powersync.connector.supabase
22

3+
import co.touchlab.kermit.Logger
34
import com.powersync.PowerSyncDatabase
45
import com.powersync.connectors.PowerSyncBackendConnector
56
import com.powersync.connectors.PowerSyncCredentials
@@ -12,6 +13,7 @@ import io.github.jan.supabase.auth.providers.builtin.Email
1213
import io.github.jan.supabase.auth.status.SessionStatus
1314
import io.github.jan.supabase.auth.user.UserSession
1415
import io.github.jan.supabase.createSupabaseClient
16+
import io.github.jan.supabase.exceptions.BadRequestRestException
1517
import io.github.jan.supabase.postgrest.Postgrest
1618
import io.github.jan.supabase.postgrest.from
1719
import kotlinx.coroutines.flow.StateFlow
@@ -136,8 +138,19 @@ public class SupabaseConnector(
136138

137139
transaction.complete(null)
138140
} catch (e: Exception) {
139-
println("Data upload error - retrying last entry: ${lastEntry!!}, $e")
140-
throw e
141+
when (e) {
142+
is BadRequestRestException -> {
143+
if (e.message?.contains("violates not-null constraint") == true) {
144+
Logger.e("Not-null constraint violation: ${e.message}")
145+
transaction.complete(null)
146+
return
147+
}
148+
}
149+
else -> {
150+
Logger.e("Data upload error - retrying last entry: $lastEntry, $e")
151+
throw e
152+
}
153+
}
141154
}
142155
}
143156
}

demos/supabase-todolist/gradle/libs.versions.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ ktor = "3.0.1"
1414
uuid = "0.8.2"
1515
buildKonfig = "0.15.1"
1616

17-
supabase = "3.0.1"
1817
junit = "4.13.2"
1918

2019
compose = "1.6.11"
@@ -51,9 +50,6 @@ ktor-client-contentnegotiation = { module = "io.ktor:ktor-client-content-negotia
5150
ktor-serialization-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
5251
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
5352

54-
supabase-client = { module = "io.github.jan-tennert.supabase:postgrest-kt", version.ref = "supabase" }
55-
supabase-auth = { module = "io.github.jan-tennert.supabase:auth-kt", version.ref = "supabase" }
56-
5753
androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core" }
5854
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
5955
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" }

demos/supabase-todolist/shared/src/commonMain/kotlin/com/powersync/demos/Auth.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope
55
import co.touchlab.kermit.Logger
66
import com.powersync.PowerSyncDatabase
77
import com.powersync.connector.supabase.SupabaseConnector
8+
import io.github.jan.supabase.auth.status.RefreshFailureCause
89
import io.github.jan.supabase.auth.status.SessionStatus
910
import kotlinx.coroutines.flow.MutableStateFlow
1011
import kotlinx.coroutines.flow.StateFlow
@@ -38,7 +39,12 @@ internal class AuthViewModel(
3839
}
3940

4041
SessionStatus.Initializing -> Logger.e("Loading from storage")
41-
SessionStatus.RefreshFailure(cause) -> Logger.e("Network error")
42+
is SessionStatus.RefreshFailure -> {
43+
when (it.cause) {
44+
is RefreshFailureCause.NetworkError -> Logger.e("Network error occurred")
45+
is RefreshFailureCause.InternalServerError -> Logger.e("Internal server error occurred")
46+
}
47+
}
4248
is SessionStatus.NotAuthenticated -> {
4349
db.disconnectAndClear()
4450
_authState.value = AuthState.SignedOut

0 commit comments

Comments
 (0)