From 356d8f1503e9c403fd2ea00ef400124017a9eac5 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Tue, 17 May 2022 14:26:56 -0500 Subject: [PATCH] try again --- package.json | 2 +- website/src/lib/dictionary-core.ts | 2 +- website/src/lib/dictionary.ts | 24 ++++++++++++++++++++---- website/src/types.d.ts | 16 ---------------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 196e1cb..cbe03e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/lingdocs-main", - "version": "0.2.6", + "version": "0.2.7", "description": "types and functions for lingdocs stuff", "main": "dist/library.js", "module": "dist/library.js", diff --git a/website/src/lib/dictionary-core.ts b/website/src/lib/dictionary-core.ts index 3341681..d0ff0d8 100644 --- a/website/src/lib/dictionary-core.ts +++ b/website/src/lib/dictionary-core.ts @@ -92,7 +92,7 @@ export class DictionaryDb { unique: ["ts"], }); this.collection.insert(dictionary.entries); - this.lokidb.saveDatabase((err) => { + this.lokidb.saveDatabase((err: any) => { /* istanbul ignore next */ if (err) { console.error("error saving database: " + err); diff --git a/website/src/lib/dictionary.ts b/website/src/lib/dictionary.ts index 57d306b..9853fa4 100644 --- a/website/src/lib/dictionary.ts +++ b/website/src/lib/dictionary.ts @@ -31,6 +31,22 @@ const dictionaryCollectionName = "dictionary3"; // const dictionaryDatabaseName = "dictdb.db"; export const pageSize = 35; +export type DictionaryAPI = { + initialize: () => Promise<{ + response: "loaded first time" | "loaded from saved", + dictionaryInfo: T.DictionaryInfo, + }>, + update: (updateComing: () => void) => Promise<{ + response: "no need for update" | "updated" | "unable to check", + dictionaryInfo: T.DictionaryInfo, + }>, + search: (state: State) => T.DictionaryEntry[], + exactPashtoSearch: (search: string) => T.DictionaryEntry[], + getNewWordsThisMonth: () => T.DictionaryEntry[], + findOneByTs: (ts: number) => T.DictionaryEntry | undefined, + findRelatedEntries: (entry: T.DictionaryEntry) => T.DictionaryEntry[], +} + const relevancySorter = new relevancy.Sorter(); const db = indexedDB.open('inPrivate'); @@ -101,7 +117,7 @@ function alphabeticalLookup({ searchString, page }: { page: number, }): T.DictionaryEntry[] { const r = new RegExp("^" + sanitizePashto(makeSearchStringSafe(searchString))); - const regexResults = dictDb.collection.find({ + const regexResults: T.DictionaryEntry[] = dictDb.collection.find({ $or: [ {p: { $regex: r }}, {g: { $regex: r }}, @@ -155,7 +171,7 @@ function englishLookup({ searchString, page, tpFilt .limit(exactResultsLimit) .simplesort("i") .data(); - resultsGiven = exactResults.map((mpd) => mpd.$loki); + resultsGiven = exactResults.map((mpd: any) => mpd.$loki); // get results with full word match at beginning of string const startingQuery = { e: { @@ -169,7 +185,7 @@ function englishLookup({ searchString, page, tpFilt .limit(startingResultsLimit) .simplesort("i") .data(); - resultsGiven = [...resultsGiven, ...startingResults.map((mpd) => mpd.$loki)]; + resultsGiven = [...resultsGiven, ...startingResults.map((mpd: any) => mpd.$loki)]; // get results with full word match anywhere const fullWordQuery = { e: { @@ -183,7 +199,7 @@ function englishLookup({ searchString, page, tpFilt .limit(fullWordResultsLimit) .simplesort("i") .data(); - resultsGiven = [...resultsGiven, ...fullWordResults.map((mpd) => mpd.$loki)] + resultsGiven = [...resultsGiven, ...fullWordResults.map((mpd: any) => mpd.$loki)] // get results with partial match anywhere const partialMatchQuery = { e: { diff --git a/website/src/types.d.ts b/website/src/types.d.ts index dfd44c2..c6320f1 100644 --- a/website/src/types.d.ts +++ b/website/src/types.d.ts @@ -92,22 +92,6 @@ type TextOptionsAction = { payload: boolean, }; -type DictionaryAPI = { - initialize: () => Promise<{ - response: "loaded first time" | "loaded from saved", - dictionaryInfo: import("@lingdocs/pashto-inflector").Types.DictionaryInfo, - }>, - update: (updateComing: () => void) => Promise<{ - response: "no need for update" | "updated" | "unable to check", - dictionaryInfo: import("@lingdocs/pashto-inflector").Types.DictionaryInfo, - }>, - search: (state: State) => import("@lingdocs/pashto-inflector").Types.DictionaryEntry[], - exactPashtoSearch: (search: string) => import("@lingdocs/pashto-inflector").Types.DictionaryEntry[], - getNewWordsThisMonth: () => import("@lingdocs/pashto-inflector").Types.DictionaryEntry[], - findOneByTs: (ts: number) => import("@lingdocs/pashto-inflector").Types.DictionaryEntry | undefined, - findRelatedEntries: (entry: import("@lingdocs/pashto-inflector").Types.DictionaryEntry) => import("@lingdocs/pashto-inflector").Types.DictionaryEntry[], -} - type AttachmentToPut = { content_type: string, data: string | blob,