Don't make a local variable when adding a Macro in ConfigScreen.kt

This commit is contained in:
Username404 2021-06-24 22:19:15 +02:00
parent c43b584096
commit dd2c01b461
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 2 additions and 4 deletions

View File

@ -88,10 +88,8 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
)
}
}.setTooltip(TranslatableComponent("$confPrefix.general.macros.tooltip")).setSaveConsumer { it.forEach { string ->
val splitString: Pair<String, String>? = string.split(":").map { toTrim -> toTrim.trimStart() }.let { element ->
if (element.size == 2) element.component1() to element.component2() else null
}; if (splitString != null) {
Macro(title = splitString.first, command = splitString.second).let { newMacro ->
with(string.split(":")) {
if (size == 2) Macro(title = component1().trimStart(), command = component2().trim()).let { newMacro ->
macrosButtons.removeIf { existingMacro ->
(existingMacro.title == newMacro.title)
|| (existingMacro.command == newMacro.command)