mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-21 06:39:09 +00:00
fix toast spam in layout editor
This commit is contained in:
parent
31f7ef6182
commit
4efc33dba4
1 changed files with 6 additions and 5 deletions
|
@ -41,7 +41,6 @@ fun LayoutEditDialog(
|
||||||
) {
|
) {
|
||||||
val ctx = LocalContext.current
|
val ctx = LocalContext.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
var job: Job? = null
|
|
||||||
val startIsCustom = LayoutUtilsCustom.isCustomLayout(initialLayoutName)
|
val startIsCustom = LayoutUtilsCustom.isCustomLayout(initialLayoutName)
|
||||||
var displayNameValue by rememberSaveable(stateSaver = TextFieldValue.Saver) {
|
var displayNameValue by rememberSaveable(stateSaver = TextFieldValue.Saver) {
|
||||||
mutableStateOf(TextFieldValue(
|
mutableStateOf(TextFieldValue(
|
||||||
|
@ -57,7 +56,7 @@ fun LayoutEditDialog(
|
||||||
|
|
||||||
TextInputDialog(
|
TextInputDialog(
|
||||||
onDismissRequest = {
|
onDismissRequest = {
|
||||||
job?.cancel()
|
errorJob?.cancel()
|
||||||
onDismissRequest()
|
onDismissRequest()
|
||||||
},
|
},
|
||||||
onConfirmed = {
|
onConfirmed = {
|
||||||
|
@ -84,10 +83,9 @@ fun LayoutEditDialog(
|
||||||
},
|
},
|
||||||
checkTextValid = {
|
checkTextValid = {
|
||||||
val valid = LayoutUtilsCustom.checkLayout(it, ctx)
|
val valid = LayoutUtilsCustom.checkLayout(it, ctx)
|
||||||
job?.cancel()
|
errorJob?.cancel()
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
job = scope.launch {
|
errorJob = scope.launch {
|
||||||
// todo: this can end up in toast-spam
|
|
||||||
val message = Log.getLog(10)
|
val message = Log.getLog(10)
|
||||||
.lastOrNull { it.tag == "LayoutUtilsCustom" }?.message
|
.lastOrNull { it.tag == "LayoutUtilsCustom" }?.message
|
||||||
?.split("\n")?.take(2)?.joinToString("\n")
|
?.split("\n")?.take(2)?.joinToString("\n")
|
||||||
|
@ -103,3 +101,6 @@ fun LayoutEditDialog(
|
||||||
reducePadding = true,
|
reducePadding = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the job is here to make sure old jobs are canceled
|
||||||
|
private var errorJob: Job? = null
|
||||||
|
|
Loading…
Add table
Reference in a new issue