diff --git a/enjoy/src/main.ts b/enjoy/src/main.ts index ac9d7b0a..53ae17fd 100644 --- a/enjoy/src/main.ts +++ b/enjoy/src/main.ts @@ -14,7 +14,7 @@ log.errorHandler.startCatching(); // Fix "getRandomValues() not supported" global.crypto = crypto; -app.commandLine.appendSwitch('enable-features','SharedArrayBuffer') +app.commandLine.appendSwitch("enable-features", "SharedArrayBuffer"); // Handle creating/removing shortcuts on Windows when installing/uninstalling. if (require("electron-squirrel-startup")) { @@ -58,7 +58,7 @@ app.on("ready", async () => { // for applications and their menu bar to stay active until the user quits // explicitly with Cmd + Q. app.on("window-all-closed", () => { - app.quit(); + app.quit(); }); app.on("activate", () => { diff --git a/enjoy/src/main/db/models/audio.ts b/enjoy/src/main/db/models/audio.ts index ae4cfd78..ff901df9 100644 --- a/enjoy/src/main/db/models/audio.ts +++ b/enjoy/src/main/db/models/audio.ts @@ -16,7 +16,7 @@ import { } from "sequelize-typescript"; import { Recording, Speech, Transcription, Video } from "@main/db/models"; import settings from "@main/settings"; -import { AudioFormats, VideoFormats } from "@/constants"; +import { AudioFormats, VideoFormats , WEB_API_URL } from "@/constants"; import { hashFile } from "@/utils"; import path from "path"; import fs from "fs-extra"; @@ -26,7 +26,6 @@ import log from "electron-log/main"; import storage from "@main/storage"; import Ffmpeg from "@main/ffmpeg"; import { Client } from "@/api"; -import { WEB_API_URL } from "@/constants"; import startCase from "lodash/startCase"; import { v5 as uuidv5 } from "uuid"; diff --git a/enjoy/src/main/db/models/video.ts b/enjoy/src/main/db/models/video.ts index 1b409d6f..d5f35183 100644 --- a/enjoy/src/main/db/models/video.ts +++ b/enjoy/src/main/db/models/video.ts @@ -16,7 +16,7 @@ import { } from "sequelize-typescript"; import { Audio, Recording, Speech, Transcription } from "@main/db/models"; import settings from "@main/settings"; -import { AudioFormats, VideoFormats } from "@/constants"; +import { AudioFormats, VideoFormats , WEB_API_URL } from "@/constants"; import { hashFile } from "@/utils"; import path from "path"; import fs from "fs-extra"; @@ -26,7 +26,6 @@ import log from "electron-log/main"; import storage from "@main/storage"; import Ffmpeg from "@main/ffmpeg"; import { Client } from "@/api"; -import { WEB_API_URL } from "@/constants"; import startCase from "lodash/startCase"; import { v5 as uuidv5 } from "uuid"; diff --git a/enjoy/src/main/ffmpeg.ts b/enjoy/src/main/ffmpeg.ts index 4a24a490..35cf7dc9 100644 --- a/enjoy/src/main/ffmpeg.ts +++ b/enjoy/src/main/ffmpeg.ts @@ -9,7 +9,7 @@ import downloader from "@main/downloader"; import storage from "@main/storage"; import readdirp from "readdirp"; import { t } from "i18next"; -import uniq from "lodash/uniq"; +import uniq from "lodash/uniq"; const logger = log.scope("ffmpeg"); export default class FfmpegWrapper { diff --git a/enjoy/src/main/whisper.ts b/enjoy/src/main/whisper.ts index 31b86903..e54fd5a1 100644 --- a/enjoy/src/main/whisper.ts +++ b/enjoy/src/main/whisper.ts @@ -5,7 +5,7 @@ import { WHISPER_MODELS_OPTIONS, PROCESS_TIMEOUT, AI_WORKER_ENDPOINT, -} from "@/constants"; + WEB_API_URL } from "@/constants"; import { exec } from "child_process"; import fs from "fs-extra"; import log from "electron-log/main"; @@ -14,7 +14,6 @@ import axios from "axios"; import { milisecondsToTimestamp } from "@/utils"; import { AzureSpeechSdk } from "@main/azure-speech-sdk"; import { Client } from "@/api"; -import { WEB_API_URL } from "@/constants"; import take from "lodash/take"; import sortedUniqBy from "lodash/sortedUniqBy"; diff --git a/enjoy/src/main/window.ts b/enjoy/src/main/window.ts index b913db4b..672faa32 100644 --- a/enjoy/src/main/window.ts +++ b/enjoy/src/main/window.ts @@ -225,6 +225,7 @@ main.init = () => { const bounds = view.getBounds(); logger.debug("current view bounds", bounds); + if (bounds.width === 0 && bounds.height === 0) return; view.setBounds({ x: -Math.round(bounds.width), diff --git a/enjoy/src/renderer/components/lookup-result.tsx b/enjoy/src/renderer/components/lookup-result.tsx index 0cd454ca..c29a621e 100644 --- a/enjoy/src/renderer/components/lookup-result.tsx +++ b/enjoy/src/renderer/components/lookup-result.tsx @@ -1,6 +1,6 @@ import { useState, useEffect } from "react"; import { LoaderSpin, MeaningCard } from "@renderer/components"; -import { Button } from "@renderer/components/ui"; +import { Button, toast } from "@renderer/components/ui"; import { t } from "i18next"; import { XCircleIcon } from "lucide-react"; import { useAiCommand } from "@renderer/hooks"; @@ -36,6 +36,9 @@ export const LookupResult = (props: { onResult && onResult(lookup.meaning); } }) + .catch((error) => { + toast.error(error.message); + }) .finally(() => { setLoading(false); }); diff --git a/enjoy/src/renderer/components/medias/media-player-controls.tsx b/enjoy/src/renderer/components/medias/media-player-controls.tsx index cf8e3205..dade06a7 100644 --- a/enjoy/src/renderer/components/medias/media-player-controls.tsx +++ b/enjoy/src/renderer/components/medias/media-player-controls.tsx @@ -319,7 +319,7 @@ export const MediaPlayerControls = (props: { - + ); }; diff --git a/enjoy/src/renderer/components/pitch-contour.tsx b/enjoy/src/renderer/components/pitch-contour.tsx index b9c22b2b..33179daf 100644 --- a/enjoy/src/renderer/components/pitch-contour.tsx +++ b/enjoy/src/renderer/components/pitch-contour.tsx @@ -25,7 +25,8 @@ export const PitchContour = (props: { height: number; id?: string; }) => { - let { peaks, sampleRate, frequencies, height, id } = props; + const { peaks, sampleRate, height, id } = props; + let { frequencies } = props; if (!frequencies) { frequencies = extractFrequencies({ peaks, sampleRate }); diff --git a/enjoy/src/renderer/components/recordings/recordings-list.tsx b/enjoy/src/renderer/components/recordings/recordings-list.tsx index 65f38dce..99e5f0d5 100644 --- a/enjoy/src/renderer/components/recordings/recordings-list.tsx +++ b/enjoy/src/renderer/components/recordings/recordings-list.tsx @@ -171,7 +171,7 @@ export const RecordingsList = (props: {
{referenceId !== undefined && Boolean(referenceText) && ( )} diff --git a/enjoy/src/renderer/components/stories/story-content.tsx b/enjoy/src/renderer/components/stories/story-content.tsx index b66b090a..dace8a05 100644 --- a/enjoy/src/renderer/components/stories/story-content.tsx +++ b/enjoy/src/renderer/components/stories/story-content.tsx @@ -22,9 +22,9 @@ export const StoryContent = (props: { content: string }) => { {paragraphs.map((sentences, i: number) => (

{sentences.map((sentence, i: number) => { - if (sentence.text.match(/\!\[\]\(\S+\)/g)) { - const [img] = sentence.text.match(/\!\[\]\(\S+\)/g); - const src = img.replace(/\!\[\]\(/g, "").replace(/\)/g, ""); + if (sentence.text.match(/!\[\]\(\S+\)/g)) { + const [img] = sentence.text.match(/!\[\]\(\S+\)/g); + const src = img.replace(/!\[\]\(/g, "").replace(/\)/g, ""); return (

diff --git a/enjoy/src/renderer/components/stories/story-viewer.tsx b/enjoy/src/renderer/components/stories/story-viewer.tsx index 890dc9e6..e067d009 100644 --- a/enjoy/src/renderer/components/stories/story-viewer.tsx +++ b/enjoy/src/renderer/components/stories/story-viewer.tsx @@ -54,7 +54,7 @@ export const StoryViewer = (props: { const word = selection .toString() .trim() - .replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]+$/, ""); + .replace(/[.,/#!$%^&*;:{}=\-_`~()]+$/, ""); if (!word) return; const position = { @@ -152,9 +152,9 @@ export const StoryViewer = (props: { {paragraphs.map((sentences, i: number) => (

{sentences.map((sentence, j: number) => { - if (sentence.text.match(/\!\[\]\(\S+\)/g)) { - const [img] = sentence.text.match(/\!\[\]\(\S+\)/g); - const src = img.replace(/\!\[\]\(/g, "").replace(/\)/g, ""); + if (sentence.text.match(/!\[\]\(\S+\)/g)) { + const [img] = sentence.text.match(/!\[\]\(\S+\)/g); + const src = img.replace(/!\[\]\(/g, "").replace(/\)/g, ""); return ; } else { return ( diff --git a/enjoy/src/renderer/hooks/useAiCommand.tsx b/enjoy/src/renderer/hooks/useAiCommand.tsx index 0ea840be..a4b34d30 100644 --- a/enjoy/src/renderer/hooks/useAiCommand.tsx +++ b/enjoy/src/renderer/hooks/useAiCommand.tsx @@ -9,8 +9,6 @@ import { translateCommand, ipaCommand, } from "@commands"; -import { toast } from "@renderer/components/ui"; -import { t } from "i18next"; import { md5 } from "js-md5"; export const useAiCommand = () => { diff --git a/enjoy/src/renderer/hooks/useConversation.tsx b/enjoy/src/renderer/hooks/useConversation.tsx index 1f5f771d..e1687cfc 100644 --- a/enjoy/src/renderer/hooks/useConversation.tsx +++ b/enjoy/src/renderer/hooks/useConversation.tsx @@ -9,7 +9,7 @@ import { ChatOpenAI } from "langchain/chat_models/openai"; import { ChatOllama } from "langchain/chat_models/ollama"; import { ChatGoogleGenerativeAI } from "@langchain/google-genai"; import { ChatPromptTemplate, MessagesPlaceholder } from "langchain/prompts"; -import OpenAI, { type ClientOptions } from "openai"; +import OpenAI from "openai"; import { type Generation } from "langchain/dist/schema"; import { v4 } from "uuid"; @@ -124,7 +124,7 @@ export const useConversation = () => { const llm = pickLlm(conversation); const chain = new ConversationChain({ - // @ts-ignore + // @ts-expect-error llm, memory, prompt, diff --git a/enjoy/src/renderer/pages/conversation.tsx b/enjoy/src/renderer/pages/conversation.tsx index b1bdeb07..64301bd5 100644 --- a/enjoy/src/renderer/pages/conversation.tsx +++ b/enjoy/src/renderer/pages/conversation.tsx @@ -23,7 +23,7 @@ import { useConversation } from "@renderer/hooks"; export default () => { const { id } = useParams<{ id: string }>(); - const [searchParams, _] = useSearchParams(); + const [searchParams] = useSearchParams(); const [editting, setEditting] = useState(false); const [conversation, setConversation] = useState(); const { addDblistener, removeDbListener } = useContext(DbProviderContext); diff --git a/enjoy/src/renderer/pages/story.tsx b/enjoy/src/renderer/pages/story.tsx index e71e39be..c2a1be3a 100644 --- a/enjoy/src/renderer/pages/story.tsx +++ b/enjoy/src/renderer/pages/story.tsx @@ -9,9 +9,7 @@ import { } from "@renderer/components"; import { useState, useContext, useEffect } from "react"; import { useParams } from "react-router-dom"; -import { - AppSettingsProviderContext, -} from "@renderer/context"; +import { AppSettingsProviderContext } from "@renderer/context"; import { useAiCommand } from "@renderer/hooks"; import nlp from "compromise"; import paragraphs from "compromise-paragraphs"; @@ -67,7 +65,7 @@ export default () => { const extractVocabulary = async () => { if (!story) return; - let { words = [], idioms = [] } = story?.extraction || {}; + const { words = [], idioms = [] } = story?.extraction || {}; if (story?.extracted && (words.length > 0 || idioms.length > 0)) return; toast.promise( diff --git a/enjoy/src/renderer/reducers/audios-reducer.ts b/enjoy/src/renderer/reducers/audios-reducer.ts index f99a7d06..0a8f6120 100644 --- a/enjoy/src/renderer/reducers/audios-reducer.ts +++ b/enjoy/src/renderer/reducers/audios-reducer.ts @@ -12,6 +12,8 @@ export const audiosReducer = ( return [...audios, action.record]; } else if (action.records) { return [...audios, ...action.records]; + } else { + return audios; } } case "create": { diff --git a/enjoy/src/renderer/reducers/messages-reducer.ts b/enjoy/src/renderer/reducers/messages-reducer.ts index bcd6d6e2..7565f085 100644 --- a/enjoy/src/renderer/reducers/messages-reducer.ts +++ b/enjoy/src/renderer/reducers/messages-reducer.ts @@ -12,6 +12,8 @@ export const messagesReducer = ( return [...messages, action.record]; } else if (action.records) { return [...messages, ...action.records]; + } else { + return messages; } } case "create": { diff --git a/enjoy/src/renderer/reducers/recordings-reducer.ts b/enjoy/src/renderer/reducers/recordings-reducer.ts index 1b94b32b..26aaca16 100644 --- a/enjoy/src/renderer/reducers/recordings-reducer.ts +++ b/enjoy/src/renderer/reducers/recordings-reducer.ts @@ -12,6 +12,8 @@ export const recordingsReducer = ( return [...recordings, action.record]; } else if (action.records) { return [...recordings, ...action.records]; + } else { + return recordings; } } case "create": { diff --git a/enjoy/src/renderer/reducers/videos-reducer.ts b/enjoy/src/renderer/reducers/videos-reducer.ts index 456099ff..6a330225 100644 --- a/enjoy/src/renderer/reducers/videos-reducer.ts +++ b/enjoy/src/renderer/reducers/videos-reducer.ts @@ -12,6 +12,8 @@ export const videosReducer = ( return [...videos, action.record]; } else if (action.records) { return [...videos, ...action.records]; + } else { + return videos; } } case "create": {