fix: deeplink does not work sometime (#4755)
* fix: deep link does not work sometime and reduce redundant request * chore: bump cortex fix
This commit is contained in:
parent
250d30d73a
commit
ad1765cd3f
@ -1 +1 @@
|
|||||||
1.0.11-rc4
|
1.0.11-rc5
|
||||||
|
|||||||
@ -6,7 +6,10 @@ import { useDebouncedCallback } from 'use-debounce'
|
|||||||
|
|
||||||
import { MainViewState } from '@/constants/screens'
|
import { MainViewState } from '@/constants/screens'
|
||||||
|
|
||||||
import { useModelSourcesMutation } from '@/hooks/useModelSource'
|
import {
|
||||||
|
useGetModelSources,
|
||||||
|
useModelSourcesMutation,
|
||||||
|
} from '@/hooks/useModelSource'
|
||||||
|
|
||||||
import { loadingModalInfoAtom } from '../LoadingModal'
|
import { loadingModalInfoAtom } from '../LoadingModal'
|
||||||
import { toaster } from '../Toast'
|
import { toaster } from '../Toast'
|
||||||
@ -19,6 +22,7 @@ const DeepLinkListener: React.FC = () => {
|
|||||||
const setLoadingInfo = useSetAtom(loadingModalInfoAtom)
|
const setLoadingInfo = useSetAtom(loadingModalInfoAtom)
|
||||||
const setMainView = useSetAtom(mainViewStateAtom)
|
const setMainView = useSetAtom(mainViewStateAtom)
|
||||||
const setModelDetail = useSetAtom(modelDetailAtom)
|
const setModelDetail = useSetAtom(modelDetailAtom)
|
||||||
|
const { mutate } = useGetModelSources()
|
||||||
|
|
||||||
const handleDeepLinkAction = useDebouncedCallback(
|
const handleDeepLinkAction = useDebouncedCallback(
|
||||||
async (deepLinkAction: DeepLinkAction) => {
|
async (deepLinkAction: DeepLinkAction) => {
|
||||||
@ -37,7 +41,7 @@ const DeepLinkListener: React.FC = () => {
|
|||||||
title: 'Getting Hugging Face model details',
|
title: 'Getting Hugging Face model details',
|
||||||
message: 'Please wait..',
|
message: 'Please wait..',
|
||||||
})
|
})
|
||||||
await addModelSource(deepLinkAction.resource)
|
await addModelSource(deepLinkAction.resource).then(() => mutate())
|
||||||
setLoadingInfo(undefined)
|
setLoadingInfo(undefined)
|
||||||
setMainView(MainViewState.Hub)
|
setMainView(MainViewState.Hub)
|
||||||
setModelDetail(deepLinkAction.resource)
|
setModelDetail(deepLinkAction.resource)
|
||||||
|
|||||||
29
web/screens/Hub/ModelPage/RemoteModelRefresh.tsx
Normal file
29
web/screens/Hub/ModelPage/RemoteModelRefresh.tsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { Button } from '@janhq/joi'
|
||||||
|
|
||||||
|
import { RefreshCwIcon } from 'lucide-react'
|
||||||
|
|
||||||
|
import Spinner from '@/containers/Loader/Spinner'
|
||||||
|
|
||||||
|
import { useRefreshModelList } from '@/hooks/useEngineManagement'
|
||||||
|
|
||||||
|
function RemoteModelRefresh({ id }: { id: string }) {
|
||||||
|
const { refreshingModels, refreshModels } = useRefreshModelList(id)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
theme={'ghost'}
|
||||||
|
variant={'outline'}
|
||||||
|
className="h-7 px-2"
|
||||||
|
onClick={() => refreshModels()}
|
||||||
|
>
|
||||||
|
{refreshingModels ? (
|
||||||
|
<Spinner size={16} strokeWidth={2} className="mr-2" />
|
||||||
|
) : (
|
||||||
|
<RefreshCwIcon size={16} className="mr-2" />
|
||||||
|
)}
|
||||||
|
Refresh
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RemoteModelRefresh
|
||||||
@ -25,6 +25,8 @@ import { MarkdownTextMessage } from '@/screens/Thread/ThreadCenterPanel/TextMess
|
|||||||
import { toGigabytes } from '@/utils/converter'
|
import { toGigabytes } from '@/utils/converter'
|
||||||
import { extractModelName, removeYamlFrontMatter } from '@/utils/modelSource'
|
import { extractModelName, removeYamlFrontMatter } from '@/utils/modelSource'
|
||||||
|
|
||||||
|
import RemoteModelRefresh from './RemoteModelRefresh'
|
||||||
|
|
||||||
import { mainViewStateAtom } from '@/helpers/atoms/App.atom'
|
import { mainViewStateAtom } from '@/helpers/atoms/App.atom'
|
||||||
import {
|
import {
|
||||||
selectedSettingAtom,
|
selectedSettingAtom,
|
||||||
@ -39,7 +41,6 @@ type Props = {
|
|||||||
const ModelPage = ({ model, onGoBack }: Props) => {
|
const ModelPage = ({ model, onGoBack }: Props) => {
|
||||||
const setSelectedSetting = useSetAtom(selectedSettingAtom)
|
const setSelectedSetting = useSetAtom(selectedSettingAtom)
|
||||||
const setMainViewState = useSetAtom(mainViewStateAtom)
|
const setMainViewState = useSetAtom(mainViewStateAtom)
|
||||||
const { refreshingModels, refreshModels } = useRefreshModelList(model.id)
|
|
||||||
const showScrollBar = useAtomValue(showScrollBarAtom)
|
const showScrollBar = useAtomValue(showScrollBarAtom)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -157,23 +158,7 @@ const ModelPage = ({ model, onGoBack }: Props) => {
|
|||||||
)}
|
)}
|
||||||
<th className="w-[120px]">
|
<th className="w-[120px]">
|
||||||
{model.type === 'cloud' && (
|
{model.type === 'cloud' && (
|
||||||
<Button
|
<RemoteModelRefresh id={model.id} />
|
||||||
theme={'ghost'}
|
|
||||||
variant={'outline'}
|
|
||||||
className="h-7 px-2"
|
|
||||||
onClick={() => refreshModels()}
|
|
||||||
>
|
|
||||||
{refreshingModels ? (
|
|
||||||
<Spinner
|
|
||||||
size={16}
|
|
||||||
strokeWidth={2}
|
|
||||||
className="mr-2"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<RefreshCwIcon size={16} className="mr-2" />
|
|
||||||
)}
|
|
||||||
Refresh
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user