Skip to content

Commit

Permalink
Merge pull request #214 from amosproj/gui/fix/path-state-no-rerender
Browse files Browse the repository at this point in the history
fixed setting of file picker paths in state to not rerender
  • Loading branch information
a-miscellaneous authored Jan 17, 2024
2 parents dc9c37f + 3b344ba commit edf85f4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ fun saveCollageCallback(
if (!savePath.endsWith(".png")) {
savePath = "$savePath.png"
}
state.value = state.value.copy(saveCollagePath = savePath)
state.value.saveCollagePath = savePath
navigator.createCollage(savePath)
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fun saveInsertedFramesCallback(
return
}
}
state.value = state.value.copy(saveInsertionsPath = savePath)
state.value.saveInsertionsPath = savePath

createInsertionsExport(savePath, navigator.getInsertedFrames())
}
Expand Down
5 changes: 3 additions & 2 deletions GUI/src/main/kotlin/ui/components/general/ProjectManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fun handleOpenProject(
) {
val file = File(path).readLines()
state.value = JsonMapper.mapper.readValue<AppState>(file.joinToString(""))
state.value = state.value.copy(openProjectPath = path)
state.value.openProjectPath = path
}

/**
Expand All @@ -100,7 +100,8 @@ fun handleSaveProject(
if (!savePath.endsWith(".json")) {
savePath = "$savePath.json"
}
state.value = state.value.copy(saveProjectPath = savePath)
state.value.saveProjectPath = savePath

val jsonData = JsonMapper.mapper.writeValueAsString(state.value)
File(savePath).writeText(jsonData)
}
2 changes: 1 addition & 1 deletion GUI/src/main/kotlin/ui/components/general/SaveableImage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private fun saveBitmapAsPng(
savePath = "$savePath.png"
}
// remember path for next time opening the file chooser
state.value = state.value.copy(saveFramePath = savePath)
state.value.saveFramePath = savePath
val file = File(savePath)
if (file.exists()) {
val overwrite = showOverwriteConfirmation()
Expand Down

0 comments on commit edf85f4

Please sign in to comment.