fix: id oob
This commit is contained in:
parent
bce3e0d9f1
commit
11dbe77448
2 changed files with 13 additions and 5 deletions
|
@ -10,6 +10,7 @@ import androidx.compose.ui.unit.dp
|
|||
import xyz.atnrch.wrench.json.JsonLayout
|
||||
import xyz.atnrch.wrench.json.SerializedWatcherEntry
|
||||
import xyz.atnrch.wrench.watcher.WatcherEntry
|
||||
import xyz.atnrch.wrench.watcher.WatcherManager
|
||||
|
||||
@Composable
|
||||
fun TopBarButtons(
|
||||
|
@ -17,13 +18,18 @@ fun TopBarButtons(
|
|||
values: MutableCollection<WatcherEntry>
|
||||
) {
|
||||
Button(onClick = {
|
||||
println(values.toList().joinToString(","))
|
||||
jsonLayout.writeLayout(SerializedWatcherEntry.fromUnserializedEntries(values.toList()))
|
||||
}) {
|
||||
Text("Save")
|
||||
}
|
||||
Spacer(Modifier.width(10.dp))
|
||||
Button(onClick = {
|
||||
values.clear()
|
||||
// not the cleanest way of doing things
|
||||
// but tbh I'm tired after working on serialization
|
||||
// for the past 2 hrs
|
||||
// TODO: Make it cleaner maybe?
|
||||
WatcherManager.CURRENT_ID = 0
|
||||
jsonLayout.readLayout()
|
||||
}) {
|
||||
Text("Load")
|
||||
|
|
|
@ -5,16 +5,18 @@ import java.io.File
|
|||
import java.nio.file.Path
|
||||
|
||||
class WatcherManager(private val entries: MutableMap<Int, WatcherEntry>) {
|
||||
private var currentId: Int = -1
|
||||
companion object {
|
||||
var CURRENT_ID: Int = -1
|
||||
}
|
||||
|
||||
fun addFile(file: File, outputs: ArrayList<Path>) {
|
||||
val watcherEntry = WatcherEntry(file, outputs)
|
||||
currentId += 1
|
||||
entries[currentId] = watcherEntry
|
||||
CURRENT_ID += 1
|
||||
entries[CURRENT_ID] = watcherEntry
|
||||
Logger.info(
|
||||
"""
|
||||
Tracking new file:
|
||||
ID: $currentId
|
||||
ID: $CURRENT_ID
|
||||
Name: ${file.name}
|
||||
Path: ${file.absolutePath}
|
||||
""".trimIndent()
|
||||
|
|
Reference in a new issue