decompose if statement
MODIFY
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Avalonia;
@@ -89,8 +90,6 @@ namespace WalletWasabi.Fluent.Controls
_disposable =
_autoCompleteBox.AddDisposableHandler(TextInputEvent, OnTextInput,
RoutingStrategies.Tunnel);
-
-
}
private void OnACBGLostFocus(object? sender, RoutedEventArgs e)
@@ -232,12 +231,21 @@ namespace WalletWasabi.Fluent.Controls
var currentText = _autoCompleteBox.Text ?? "";
var currentTextTrimmed = currentText.Trim();
+ if (RestrictInputToSuggestions && Suggestions is IList<string> suggestions)
+ {
+ var keywordIsInSuggestions = suggestions.Any(x => x.Equals(currentTextTrimmed,
+ StringComparison.InvariantCultureIgnoreCase));
+
+ if (!keywordIsInSuggestions)
+ {
+ return;
+ }
+ }
+
if (!_isInputEnabled ||
currentText.Length < 1 ||
string.IsNullOrEmpty(currentTextTrimmed) ||
- !currentText.EndsWith(' ') ||
- RestrictInputToSuggestions && !Suggestions.Cast<string>().Any(x => x.Equals(currentTextTrimmed,
- StringComparison.InvariantCultureIgnoreCase)))
+ !currentText.EndsWith(' '))
return;
AddTag(currentTextTrimmed);

decompose if statement