fix: Dispatchers.Default pour la compat native iOS (IO internal en K/N)
This commit is contained in:
1 file changed
+2
-2
@@ -14,7 +14,7 @@ class HistoryRepository(
|
||||
) {
|
||||
private val json = Json { ignoreUnknownKeys = true }
|
||||
|
||||
suspend fun load(): List<GameResult> = withContext(Dispatchers.IO) {
|
||||
suspend fun load(): List<GameResult> = 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))
|
||||
|
||||
Reference in new issue
Block a user