Skip to content

Commit

Permalink
Move to stdlib Uuid (#1405)
Browse files Browse the repository at this point in the history
Co-authored-by: Ashley Davies <[email protected]>
  • Loading branch information
ashdavies and ashdavies authored Dec 17, 2024
1 parent 037dcdd commit 290ead1
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package io.ashdavies.party.gallery

import io.ashdavies.content.PlatformContext
import io.ashdavies.util.randomUuid
import kotlinx.coroutines.withContext
import java.io.File
import kotlin.coroutines.CoroutineContext
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

internal actual fun StorageManager(
pathProvider: PathProvider,
coroutineContext: CoroutineContext,
): StorageManager = object : StorageManager {

@OptIn(ExperimentalUuidApi::class)
override suspend fun create(platformContext: PlatformContext): File = withContext(coroutineContext) {
File(pathProvider.getImagesPath(), "${randomUuid()}.jpg").apply {
File(pathProvider.getImagesPath(), "${Uuid.random()}.jpg").apply {
require(createNewFile()) { "File already exists" }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package io.ashdavies.party.gallery

import io.ashdavies.content.PlatformContext
import io.ashdavies.sql.mapToList
import io.ashdavies.util.randomUuid
import kotlinx.coroutines.flow.Flow
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

internal interface ImageManager {
val list: Flow<List<Image>>
Expand All @@ -28,9 +29,10 @@ internal fun ImageManager(
.selectAll()
.mapToList()

@OptIn(ExperimentalUuidApi::class)
override fun add(file: File) {
val image = Image(
uuid = randomUuid(),
uuid = "${Uuid.random()}",
name = file.getName(),
path = file.getAbsolutePath(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import io.ashdavies.http.DefaultHttpConfiguration
import io.ashdavies.party.gallery.SyncManager
import io.ashdavies.party.gallery.SyncState
import io.ashdavies.party.gallery.inMemoryHttpClientEngine
import io.ashdavies.util.randomUuid
import io.ktor.client.HttpClient
import io.ktor.utils.io.ByteReadChannel
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

private val RandomImage = "${randomUuid()}.jpg"
@OptIn(ExperimentalUuidApi::class)
private val RandomImage = "${Uuid.random()}.jpg"

internal class SyncManagerTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package io.ashdavies.party.gallery

import io.ashdavies.content.PlatformContext
import io.ashdavies.util.randomUuid
import kotlinx.coroutines.withContext
import java.io.File
import kotlin.coroutines.CoroutineContext
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

internal actual fun StorageManager(
pathProvider: PathProvider,
coroutineContext: CoroutineContext,
): StorageManager = object : StorageManager {

@OptIn(ExperimentalUuidApi::class)
override suspend fun create(platformContext: PlatformContext): File = withContext(coroutineContext) {
File(pathProvider.getImagesPath(), "${randomUuid()}.jpg").apply {
File(pathProvider.getImagesPath(), "${Uuid.random()}.jpg").apply {
require(createNewFile()) { "File already exists" }
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package io.ashdavies.identity

import io.ashdavies.content.PlatformContext
import io.ashdavies.util.randomUuid
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

internal expect class GoogleIdIdentityService(
context: PlatformContext,
) : IdentityService<GoogleIdIdentityRequest>

@OptIn(ExperimentalUuidApi::class)
internal data class GoogleIdIdentityRequest(
val serverClientId: String,
val autoSelectEnabled: Boolean = true,
val nonce: String? = randomUuid(),
val nonce: String = "${Uuid.random()}",
) : IdentityRequest

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 290ead1

Please sign in to comment.