Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions apps/mobile/src/lib/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export const rehydrateOramaDb = async (): Promise<void> => {
entry.examples,
z.array(ExampleSchema)
);
const morphologyResult = safeJsonParse(
entry.morphology,
MorphologySchema
);

if (
!(
Expand All @@ -94,9 +98,14 @@ export const rehydrateOramaDb = async (): Promise<void> => {
continue;
}

const morphology = morphologyResult.ok
? morphologyResult.value
: undefined;

documents.push({
id: entry.id,
word: entry.word,
word_exact: entry.word,
translation: entry.translation,
created_at: entry.created_at ?? undefined,
created_at_timestamp_ms: entry.created_at_timestamp_ms ?? undefined,
Expand All @@ -106,6 +115,30 @@ export const rehydrateOramaDb = async (): Promise<void> => {
type: entry.type ?? undefined,
root: rootResult.value ?? undefined,
tags: tagsResult.value ?? undefined,
morphology: morphology
? {
ism: morphology.ism
? {
singular: morphology.ism.singular,
plurals: morphology.ism.plurals?.map((p) => p.word),
singular_exact: morphology.ism.singular,
plurals_exact: morphology.ism.plurals?.map((p) => p.word),
}
: undefined,
verb: morphology.verb
? {
past_tense: morphology.verb.past_tense,
present_tense: morphology.verb.present_tense,
masadir: morphology.verb.masadir?.map((m) => m.word),
past_tense_exact: morphology.verb.past_tense,
present_tense_exact: morphology.verb.present_tense,
masadir_exact: morphology.verb.masadir?.map(
(m) => m.word
),
}
: undefined,
}
: undefined,
});
}

Expand Down Expand Up @@ -229,9 +262,14 @@ export const hydrateOramaDb = async (): Promise<
continue;
}

const morphology = morphologyResult.ok
? morphologyResult.value
: undefined;

documents.push({
id: entry.id,
word: entry.word,
word_exact: entry.word,
translation: entry.translation,
created_at: entry.created_at ?? undefined,
created_at_timestamp_ms: entry.created_at_timestamp_ms ?? undefined,
Expand All @@ -241,6 +279,30 @@ export const hydrateOramaDb = async (): Promise<
type: entry.type ?? undefined,
root: rootResult.value ?? undefined,
tags: tagsResult.value ?? undefined,
morphology: morphology
? {
ism: morphology.ism
? {
singular: morphology.ism.singular,
plurals: morphology.ism.plurals?.map((p) => p.word),
singular_exact: morphology.ism.singular,
plurals_exact: morphology.ism.plurals?.map((p) => p.word),
}
: undefined,
verb: morphology.verb
? {
past_tense: morphology.verb.past_tense,
present_tense: morphology.verb.present_tense,
masadir: morphology.verb.masadir?.map((m) => m.word),
past_tense_exact: morphology.verb.past_tense,
present_tense_exact: morphology.verb.present_tense,
masadir_exact: morphology.verb.masadir?.map(
(m) => m.word
),
}
: undefined,
}
: undefined,
});
}

Expand Down
16 changes: 16 additions & 0 deletions apps/web/src/atoms/suggested-tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { atomWithStorage } from "jotai/utils";

export const suggestedTagsAtom = atomWithStorage<string[]>(
"suggested-tags",
[],
{
getItem: (key) => {
const val = sessionStorage.getItem(key);
return val ? JSON.parse(val) : [];
Comment thread
Shunseii marked this conversation as resolved.
},
setItem: (key, val) => {
sessionStorage.setItem(key, JSON.stringify(val));
},
removeItem: (key) => sessionStorage.removeItem(key),
}
);
Loading