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 }
|
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()
|
if (!fileSystem.exists(filePath)) return@withContext emptyList()
|
||||||
fileSystem.read(filePath) { readUtf8() }
|
fileSystem.read(filePath) { readUtf8() }
|
||||||
.let { json.decodeFromString(ListSerializer(GameResult.serializer()), it) }
|
.let { json.decodeFromString(ListSerializer(GameResult.serializer()), it) }
|
||||||
@@ -22,7 +22,7 @@ class HistoryRepository(
|
|||||||
|
|
||||||
suspend fun save(result: GameResult) {
|
suspend fun save(result: GameResult) {
|
||||||
val all = load() + result
|
val all = load() + result
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.Default) {
|
||||||
filePath.parent?.let { fileSystem.createDirectories(it) }
|
filePath.parent?.let { fileSystem.createDirectories(it) }
|
||||||
fileSystem.write(filePath) {
|
fileSystem.write(filePath) {
|
||||||
writeUtf8(json.encodeToString(ListSerializer(GameResult.serializer()), all))
|
writeUtf8(json.encodeToString(ListSerializer(GameResult.serializer()), all))
|
||||||
|
|||||||
Reference in new issue
Block a user