From 68cdcbda1aaf8bc4b35231da29449921ddf6e2a9 Mon Sep 17 00:00:00 2001 From: rampaa Date: Sat, 14 Dec 2024 19:19:33 +0300 Subject: [PATCH] Remove the lookup throttle option --- JL.Core/Config/CoreConfigManager.cs | 2 -- JL.Core/Lookup/LookupUtils.cs | 11 ----------- JL.Windows/ConfigManager.cs | 5 ----- JL.Windows/GUI/PreferencesWindow.xaml | 8 -------- 4 files changed, 26 deletions(-) diff --git a/JL.Core/Config/CoreConfigManager.cs b/JL.Core/Config/CoreConfigManager.cs index 147cce53..cd6e029a 100644 --- a/JL.Core/Config/CoreConfigManager.cs +++ b/JL.Core/Config/CoreConfigManager.cs @@ -16,7 +16,6 @@ public sealed class CoreConfigManager public bool ForceSyncAnki { get; private set; } // = false; public bool AllowDuplicateCards { get; private set; } // = false; public bool CheckForDuplicateCards { get; private set; } // = false; - public double LookupRate { get; private set; } // = 0; public bool CaptureTextFromClipboard { get; set; } = true; public bool CaptureTextFromWebSocket { get; set; } // = false; public bool AutoReconnectToWebSocket { get; private set; } // = false; @@ -97,7 +96,6 @@ public void ApplyPreferences(SqliteConnection connection) ForceSyncAnki = ConfigDBManager.GetValueFromConfig(connection, ForceSyncAnki, nameof(ForceSyncAnki), bool.TryParse); AllowDuplicateCards = ConfigDBManager.GetValueFromConfig(connection, AllowDuplicateCards, nameof(AllowDuplicateCards), bool.TryParse); CheckForDuplicateCards = ConfigDBManager.GetValueFromConfig(connection, CheckForDuplicateCards, nameof(CheckForDuplicateCards), bool.TryParse); - LookupRate = ConfigDBManager.GetNumberWithDecimalPointFromConfig(connection, LookupRate, nameof(LookupRate), double.TryParse); TextBoxTrimWhiteSpaceCharacters = ConfigDBManager.GetValueFromConfig(connection, TextBoxTrimWhiteSpaceCharacters, nameof(TextBoxTrimWhiteSpaceCharacters), bool.TryParse); TextBoxRemoveNewlines = ConfigDBManager.GetValueFromConfig(connection, TextBoxRemoveNewlines, nameof(TextBoxRemoveNewlines), bool.TryParse); CheckForJLUpdatesOnStartUp = ConfigDBManager.GetValueFromConfig(connection, CheckForJLUpdatesOnStartUp, nameof(CheckForJLUpdatesOnStartUp), bool.TryParse); diff --git a/JL.Core/Lookup/LookupUtils.cs b/JL.Core/Lookup/LookupUtils.cs index 5b4b086c..fadde9df 100644 --- a/JL.Core/Lookup/LookupUtils.cs +++ b/JL.Core/Lookup/LookupUtils.cs @@ -1,5 +1,4 @@ using System.Collections.Concurrent; -using System.Diagnostics; using JL.Core.Config; using JL.Core.Deconjugation; using JL.Core.Dicts; @@ -20,22 +19,12 @@ namespace JL.Core.Lookup; public static class LookupUtils { - private static DateTime s_lastLookupTime; - private delegate Dictionary>? GetRecordsFromDB(string dbName, List terms, string parameterOrQuery); private delegate List? GetKanjiRecordsFromDB(string dbName, string term); public static LookupResult[]? LookupText(string text) { CoreConfigManager coreConfigManager = CoreConfigManager.Instance; - DateTime preciseTimeNow = new(Stopwatch.GetTimestamp()); - if ((preciseTimeNow - s_lastLookupTime).TotalMilliseconds < coreConfigManager.LookupRate) - { - return null; - } - - s_lastLookupTime = preciseTimeNow; - bool useDBForPitchDict = false; if (DictUtils.SingleDictTypeDicts.TryGetValue(DictType.PitchAccentYomichan, out Dict? pitchDict)) { diff --git a/JL.Windows/ConfigManager.cs b/JL.Windows/ConfigManager.cs index 74868122..05a315c5 100644 --- a/JL.Windows/ConfigManager.cs +++ b/JL.Windows/ConfigManager.cs @@ -837,7 +837,6 @@ public void LoadPreferenceWindow(PreferencesWindow preferenceWindow) preferenceWindow.ForceSyncAnkiCheckBox.IsChecked = coreConfigManager.ForceSyncAnki; preferenceWindow.AllowDuplicateCardsCheckBox.IsChecked = coreConfigManager.AllowDuplicateCards; preferenceWindow.CheckForDuplicateCardsCheckBox.IsChecked = coreConfigManager.CheckForDuplicateCards; - preferenceWindow.LookupRateNumericUpDown.Value = coreConfigManager.LookupRate; preferenceWindow.KanjiModeCheckBox.IsChecked = coreConfigManager.KanjiMode; preferenceWindow.AutoAdjustFontSizesOnResolutionChangeCheckBox.IsChecked = AutoAdjustFontSizesOnResolutionChange; preferenceWindow.HighlightLongestMatchCheckBox.IsChecked = HighlightLongestMatch; @@ -853,7 +852,6 @@ public void LoadPreferenceWindow(PreferencesWindow preferenceWindow) preferenceWindow.FocusableCheckBox.IsChecked = Focusable; preferenceWindow.TextOnlyVisibleOnHoverCheckBox.IsChecked = TextOnlyVisibleOnHover; preferenceWindow.AnkiIntegrationCheckBox.IsChecked = coreConfigManager.AnkiIntegration; - preferenceWindow.LookupRateNumericUpDown.Value = coreConfigManager.LookupRate; preferenceWindow.MainWindowDynamicWidthCheckBox.IsChecked = MainWindowDynamicWidth; preferenceWindow.MainWindowDynamicHeightCheckBox.IsChecked = MainWindowDynamicHeight; @@ -1209,9 +1207,6 @@ public async Task SavePreferences(PreferencesWindow preferenceWindow) ConfigDBManager.UpdateSetting(connection, nameof(CoreConfigManager.CheckForDuplicateCards), preferenceWindow.CheckForDuplicateCardsCheckBox.IsChecked.ToString()!); - ConfigDBManager.UpdateSetting(connection, nameof(CoreConfigManager.LookupRate), - preferenceWindow.LookupRateNumericUpDown.Value.ToString(CultureInfo.InvariantCulture)); - ConfigDBManager.UpdateSetting(connection, nameof(AutoAdjustFontSizesOnResolutionChange), preferenceWindow.AutoAdjustFontSizesOnResolutionChangeCheckBox.IsChecked.ToString()!); diff --git a/JL.Windows/GUI/PreferencesWindow.xaml b/JL.Windows/GUI/PreferencesWindow.xaml index afb9dc82..aba35d74 100644 --- a/JL.Windows/GUI/PreferencesWindow.xaml +++ b/JL.Windows/GUI/PreferencesWindow.xaml @@ -1665,14 +1665,6 @@ HorizontalAlignment="Right" /> - - - - -