Add useStorage hook to remember recently used model
This commit is contained in:
parent
cfcf718769
commit
49d7f3307f
@ -8,6 +8,7 @@ import { useState } from "react"
|
|||||||
import { useForm } from "@mantine/form"
|
import { useForm } from "@mantine/form"
|
||||||
import { Download, RotateCcw, Trash2 } from "lucide-react"
|
import { Download, RotateCcw, Trash2 } from "lucide-react"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
|
import { useStorage } from "@plasmohq/storage/hook"
|
||||||
|
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ export const ModelsBody = () => {
|
|||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const { t } = useTranslation(["settings", "common"])
|
const { t } = useTranslation(["settings", "common"])
|
||||||
|
const [selectedModel, setSelectedModel] = useStorage("selectedModel")
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
@ -131,6 +133,12 @@ export const ModelsBody = () => {
|
|||||||
window.confirm(t("manageModels.confirm.delete"))
|
window.confirm(t("manageModels.confirm.delete"))
|
||||||
) {
|
) {
|
||||||
deleteOllamaModel(record.model)
|
deleteOllamaModel(record.model)
|
||||||
|
if (
|
||||||
|
selectedModel &&
|
||||||
|
selectedModel === record.model
|
||||||
|
) {
|
||||||
|
setSelectedModel(null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="text-red-500 dark:text-red-400">
|
className="text-red-500 dark:text-red-400">
|
||||||
@ -193,8 +201,7 @@ export const ModelsBody = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
defaultExpandAllRows: false,
|
defaultExpandAllRows: false
|
||||||
|
|
||||||
}}
|
}}
|
||||||
bordered
|
bordered
|
||||||
dataSource={data}
|
dataSource={data}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user