From d823836c1f6d999e9da7565c5075db1e1c2a5a5b Mon Sep 17 00:00:00 2001 From: Next Alone <12210746+NextAlone@users.noreply.github.com> Date: Sun, 14 Jul 2024 20:54:38 +0800 Subject: [PATCH] feat: trim leading and trailing `|` in message filter Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com> --- TMessagesProj/src/main/java/xyz/nextalone/nnngram/UI.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TMessagesProj/src/main/java/xyz/nextalone/nnngram/UI.kt b/TMessagesProj/src/main/java/xyz/nextalone/nnngram/UI.kt index d9ff00776..9f7ccb6a9 100644 --- a/TMessagesProj/src/main/java/xyz/nextalone/nnngram/UI.kt +++ b/TMessagesProj/src/main/java/xyz/nextalone/nnngram/UI.kt @@ -89,9 +89,9 @@ fun ChatSettingActivity.createMessageFilterSetter(context: Context, resourcesPro setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null) setPositiveButton(LocaleController.getString("Save", R.string.Save)) { _, _ -> runCatching { - if (!editText.text.isNullOrEmpty()) Pattern.compile(editText.text.toString()) + if (!editText.text.isNullOrEmpty()) Pattern.compile(editText.text.toString().trim { it == '|' }) }.onSuccess { - Config.messageFilter = editText.text.toString() + Config.messageFilter = editText.text.toString().trim { it == '|' } }.onFailure { Toast.makeText(context, LocaleController.getString("InvalidPattern", R.string.InvalidPattern), Toast.LENGTH_SHORT).show() }