-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug writer #638
base: master
Are you sure you want to change the base?
Debug writer #638
Conversation
@@ -0,0 +1,4 @@ | |||
Compose Desktop Application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to change README :)
@@ -0,0 +1,4 @@ | |||
Compose Desktop Application | |||
|
|||
- `./gradlew run` - run application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
private val fileName = "${System.getProperty("user.home")}/.debug-writer/debug-info.txt" | ||
private var output by mutableStateOf("") | ||
private var isReady by mutableStateOf(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we set this to 'false' by default then we will show Loading immediately on the first frame
} | ||
|
||
if (result) { | ||
writeDebugInfo() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid launching a coroutine on every recomposition, better to write something like this:
...
Button("Refresh", Modifier.weight(1f), {
isReady = false
GlobalScope.launch { writeDebugInfo() }
})
...
if (result) {
LaunchedEffect(Unit) {
writeDebugInfo()
}
}
...
private suspend fun writeDebugInfo() {
delay(2000L)
val result = readDebugOutput(fileName)
output = if (result.isEmpty()) "Something went wrong and $fileName is empty." else result
isReady = true
}
Loader(Modifier.weight(1f).fillMaxWidth()) | ||
} | ||
Row(modifier = Modifier.fillMaxWidth()) { | ||
Button("Refresh", Modifier.weight(1f), { writeDebugInfo() }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid multiple parallel writings when user clicks multiple times better to hide/disable button when isReady == true
fun main() { | ||
val result = enableDebugWritingTo(fileName) | ||
if (!result) { | ||
output = "Failed to cteate file: $fileName" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"create".
Overall placement of this code here looks somewhat strange, can we have it somewhere below and have an option to write to file in the way user wants it or copy-paste to clipboard.
…c when using CFD.
6419067
to
507ddfd
Compare
Is this still being worked on? |
DebugWriterTool - simple app for getting basic info about PC/Mac when using CFD.