Skip to content

Commit

Permalink
Merge pull request #386 from mitmedialab/text-classifier-modal
Browse files Browse the repository at this point in the history
modal fix
  • Loading branch information
mayarajan3 authored Dec 20, 2024
2 parents 9f2e593 + ea89e00 commit 1298cdd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion extensions/src/textClassification/ImportExport.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
extension.buildCustomDeepModel();
close();
};
const _close = async () => {
if (file) {
const success = await extension.importClassifier(file);
if (!success) close();
extension.buildCustomDeepModel();
}
close();
}
</script>

<div style:background-color={color.ui.white}>
Expand All @@ -33,7 +42,7 @@
on:change={(e) => (file = e.currentTarget.files[0])}
/>
</PrimaryButton>
<PrimaryButton on:click={close}>Done</PrimaryButton>
<PrimaryButton on:click={_close}>Done</PrimaryButton>
</div>

<style>
Expand Down
4 changes: 2 additions & 2 deletions extensions/src/textClassification/services/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const getTranslationToEnglish = async (words: string) => {
if (cachedTranslations.has(words)) return cachedTranslations.get(words);
const endpoint = getTranslationURL({ language: "en", text: encodeURIComponent(words) });
try {
const json: { result: string } = await (await fetchWithTimeout(endpoint, { timeoutMs: 30 })).json();
const translated = json.result;
const json: { result: string } = await (await fetchWithTimeout(endpoint, { timeoutMs: 1000 })).json();
const translated = json.result.replaceAll("%20", " ");
cachedTranslations.set(words, translated);
return translated;
}
Expand Down

0 comments on commit 1298cdd

Please sign in to comment.