Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-tennert authored Feb 22, 2024
2 parents 14c9555 + 86accdd commit d4b5a85
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
uses: gradle/actions/[email protected]
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
cache-read-only: true
cache-read-only: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/development' }}
- name: Analyze code using detekt
run: ./gradlew detektAll --stacktrace --configuration-cache
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PostgrestRequestBuilder(@PublishedApi internal val propertyConversionMetho
* @param referencedTable If the column is from a foreign table, specify the table name here
*/
fun order(column: String, order: Order, nullsFirst: Boolean = false, referencedTable: String? = null) {
val key = if (referencedTable == null) "order" else "\"$referencedTable\".order"
val key = if (referencedTable == null) "order" else "$referencedTable.order"
_params[key] = listOf("${column}.${order.value}.${if (nullsFirst) "nullsfirst" else "nullslast"}")
}

Expand All @@ -77,7 +77,7 @@ class PostgrestRequestBuilder(@PublishedApi internal val propertyConversionMetho
* @param referencedTable If the column is from a foreign table, specify the table name here
*/
fun limit(count: Long, referencedTable: String? = null) {
val key = if (referencedTable == null) "limit" else "\"$referencedTable\".limit"
val key = if (referencedTable == null) "limit" else "$referencedTable.limit"
_params[key] = listOf(count.toString())
}

Expand All @@ -88,8 +88,8 @@ class PostgrestRequestBuilder(@PublishedApi internal val propertyConversionMetho
* @param referencedTable If the column is from a foreign table, specify the table name here
*/
fun range(from: Long, to: Long, referencedTable: String? = null) {
val keyOffset = if (referencedTable == null) "offset" else "\"$referencedTable\".offset"
val keyLimit = if (referencedTable == null) "limit" else "\"$referencedTable\".limit"
val keyOffset = if (referencedTable == null) "offset" else "$referencedTable.offset"
val keyLimit = if (referencedTable == null) "limit" else "$referencedTable.limit"

_params[keyOffset] = listOf(from.toString())
_params[keyLimit] = listOf((to - from + 1).toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PostgrestRequestBuilderTest {
val request = postgrestRequest {
order("messages", Order.ASCENDING, true, "table")
}
assertEquals(listOf("messages.asc.nullsfirst"), request.params["\"table\".order"])
assertEquals(listOf("messages.asc.nullsfirst"), request.params["table.order"])
}

@Test
Expand All @@ -69,7 +69,7 @@ class PostgrestRequestBuilderTest {
val request = postgrestRequest {
limit(10, "table")
}
assertEquals(listOf("10"), request.params["\"table\".limit"])
assertEquals(listOf("10"), request.params["table.limit"])
}

@Test
Expand All @@ -86,8 +86,8 @@ class PostgrestRequestBuilderTest {
val request = postgrestRequest {
range(10, 20, "table")
}
assertEquals(listOf("10"), request.params["\"table\".offset"])
assertEquals(listOf("11"), request.params["\"table\".limit"])
assertEquals(listOf("10"), request.params["table.offset"])
assertEquals(listOf("11"), request.params["table.limit"])
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.isActive
import kotlinx.coroutines.job
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.serialization.json.buildJsonObject
import kotlin.time.Duration.Companion.milliseconds

Expand All @@ -47,6 +49,7 @@ internal class RealtimeImpl(override val supabaseClient: SupabaseClient, overrid
override val subscriptions: Map<String, RealtimeChannel>
get() = _subscriptions.toMap()
private val scope = CoroutineScope(Dispatchers.Default + SupervisorJob())
private val mutex = Mutex()
var heartbeatJob: Job? = null
var messageJob: Job? = null
var ref by atomic(0)
Expand All @@ -63,7 +66,7 @@ internal class RealtimeImpl(override val supabaseClient: SupabaseClient, overrid

override suspend fun connect() = connect(false)

suspend fun connect(reconnect: Boolean) {
suspend fun connect(reconnect: Boolean): Unit = mutex.withLock {
if (reconnect) {
delay(config.reconnectDelay)
Realtime.logger.d { "Reconnecting..." }
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ googleid = "1.1.0"
compose = "1.6.0-rc01"
androidsvg = "1.4"
coil = "2.5.0"
imageloader = "1.7.4"
imageloader = "1.7.5"
okio = "3.8.0"
credentials = "1.2.0"

Expand Down

0 comments on commit d4b5a85

Please sign in to comment.