Skip to content

Commit

Permalink
Remove the lookup throttle option
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Dec 14, 2024
1 parent e284a8f commit 68cdcbd
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 26 deletions.
2 changes: 0 additions & 2 deletions JL.Core/Config/CoreConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 0 additions & 11 deletions JL.Core/Lookup/LookupUtils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Concurrent;
using System.Diagnostics;
using JL.Core.Config;
using JL.Core.Deconjugation;
using JL.Core.Dicts;
Expand All @@ -20,22 +19,12 @@ namespace JL.Core.Lookup;

public static class LookupUtils
{
private static DateTime s_lastLookupTime;

private delegate Dictionary<string, IList<IDictRecord>>? GetRecordsFromDB(string dbName, List<string> terms, string parameterOrQuery);
private delegate List<IDictRecord>? 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))
{
Expand Down
5 changes: 0 additions & 5 deletions JL.Windows/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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()!);

Expand Down
8 changes: 0 additions & 8 deletions JL.Windows/GUI/PreferencesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1665,14 +1665,6 @@
HorizontalAlignment="Right" />
</DockPanel>

<DockPanel>
<TextBlock HorizontalAlignment="Left" Text="Lookup throttle (ms)"
Style="{StaticResource TextBlockDefault}"
TextWrapping="Wrap" VerticalAlignment="Center" />
<hc:NumericUpDown x:Name="LookupRateNumericUpDown" Maximum="100" Minimum="0"
HorizontalAlignment="Right" />
</DockPanel>

<DockPanel>
<TextBlock HorizontalAlignment="Left" Text="Max number of results when not in mining mode"
TextWrapping="Wrap" VerticalAlignment="Center"
Expand Down

0 comments on commit 68cdcbd

Please sign in to comment.