From 055f91af3a20e5ea69530358bda0b4c5259a8d08 Mon Sep 17 00:00:00 2001 From: Sean Beyer Date: Mon, 16 Dec 2024 09:44:53 -0800 Subject: [PATCH 1/2] Update ai highlighter on tab in and not service init --- app/components-react/pages/Highlighter.tsx | 14 +++++++++++++- app/services/highlighter/index.ts | 11 +---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/components-react/pages/Highlighter.tsx b/app/components-react/pages/Highlighter.tsx index e3007af82817..158aadb072c1 100644 --- a/app/components-react/pages/Highlighter.tsx +++ b/app/components-react/pages/Highlighter.tsx @@ -1,6 +1,6 @@ import SettingsView from 'components-react/highlighter/SettingsView'; import { useVuex } from 'components-react/hooks'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { EHighlighterView, IViewState } from 'services/highlighter'; import { Services } from 'components-react/service-provider'; import StreamView from 'components-react/highlighter/StreamView'; @@ -32,6 +32,18 @@ export default function Highlighter(props: { params?: { view: string } }) { initialViewState = { view: EHighlighterView.SETTINGS }; } + useEffect(() => { + // check if ai highlighter is activated and we need to update it + async function shouldUpdate() { + const versionAvailable = await HighlighterService.aiHighlighterUpdater.isNewVersionAvailable(); + return versionAvailable && aiHighlighterEnabled && v.useAiHighlighter; + } + + shouldUpdate().then(shouldUpdate => { + if (shouldUpdate) HighlighterService.actions.startUpdater(); + }); + }, []); + const [viewState, setViewState] = useState(initialViewState); const updaterModal = ( Date: Mon, 16 Dec 2024 12:14:38 -0800 Subject: [PATCH 2/2] Fix test --- app/components-react/pages/Highlighter.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/app/components-react/pages/Highlighter.tsx b/app/components-react/pages/Highlighter.tsx index 158aadb072c1..9a2978eeed60 100644 --- a/app/components-react/pages/Highlighter.tsx +++ b/app/components-react/pages/Highlighter.tsx @@ -35,6 +35,7 @@ export default function Highlighter(props: { params?: { view: string } }) { useEffect(() => { // check if ai highlighter is activated and we need to update it async function shouldUpdate() { + if (!HighlighterService.aiHighlighterUpdater) return false; const versionAvailable = await HighlighterService.aiHighlighterUpdater.isNewVersionAvailable(); return versionAvailable && aiHighlighterEnabled && v.useAiHighlighter; }