Skip to content

ProCraft for Android: An Android native painting app written in Rust

Rust

fix(open): an opened artwork isn't saved again as it opens, only a new one

Josh4757aa8916d5
diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasViewModel.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasViewModel.kt
index 48304d6..f81ba54 100644
--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasViewModel.kt
+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasViewModel.kt
@@ -1954,8 +1954,8 @@ class CanvasViewModel(app: Application) : AndroidViewModel(app) {
readSetChoices()
currentBrush = s.currentBrush()
screen = Screen.CANVAS
- // a new artwork exists in the gallery from the start
- viewModelScope.launch(Dispatchers.IO) { runCatching { s.save(dir.path) } }
+ // a new artwork exists in the gallery from the start (an opened one is there already)
+ if (!File(dir, "artwork.json").exists()) viewModelScope.launch(Dispatchers.IO) { runCatching { s.save(dir.path) } }
startAutosave(s, dir)
}