Skip to content

Commit

Permalink
Merge pull request #17 from kartikvirendrar/master
Browse files Browse the repository at this point in the history
add suggestions to cache only if api returns non empty array
  • Loading branch information
ishvindersethi22 authored Jul 24, 2024
2 parents c25b797 + 8376652 commit 01f2390
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ai4bharat/indic-transliterate",
"version": "1.3.5",
"version": "1.3.6",
"description": "Transliterate component for React",
"author": "AI4Bharat",
"license": "MIT",
Expand Down
6 changes: 1 addition & 5 deletions src/util/suggestions-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type CacheEntry = {

const MAX_CACHE_SIZE = 10000;
const SAVE_THRESHOLD = 20;
const CACHE_KEY = 'transliterateCache';
const CACHE_KEY = 'transliterationCache';

const cache: Record<string, Record<string, CacheEntry>> = loadCacheFromLocalStorage();
let newEntriesCount = 0;
Expand Down Expand Up @@ -111,10 +111,6 @@ export const getTransliterateSuggestions = async (
} else {
if (showCurrentWordAsLastSuggestion) {
const fallback = [word];
cache[lang][word.toLowerCase()] = {
suggestions: fallback,
frequency: 1,
};
return fallback;
}
return [];
Expand Down

0 comments on commit 01f2390

Please sign in to comment.