diff --git a/sharedUI/src/commonMain/kotlin/com/livrets/data/HistoryRepository.kt b/sharedUI/src/commonMain/kotlin/com/livrets/data/HistoryRepository.kt index f85d090..171a0eb 100644 --- a/sharedUI/src/commonMain/kotlin/com/livrets/data/HistoryRepository.kt +++ b/sharedUI/src/commonMain/kotlin/com/livrets/data/HistoryRepository.kt @@ -14,7 +14,7 @@ class HistoryRepository( ) { private val json = Json { ignoreUnknownKeys = true } - suspend fun load(): List = withContext(Dispatchers.IO) { + suspend fun load(): List = withContext(Dispatchers.Default) { if (!fileSystem.exists(filePath)) return@withContext emptyList() fileSystem.read(filePath) { readUtf8() } .let { json.decodeFromString(ListSerializer(GameResult.serializer()), it) } @@ -22,7 +22,7 @@ class HistoryRepository( suspend fun save(result: GameResult) { val all = load() + result - withContext(Dispatchers.IO) { + withContext(Dispatchers.Default) { filePath.parent?.let { fileSystem.createDirectories(it) } fileSystem.write(filePath) { writeUtf8(json.encodeToString(ListSerializer(GameResult.serializer()), all))