fix: loader error change folder
This commit is contained in:
parent
5e13fd2f53
commit
00c4397be6
@ -10,13 +10,15 @@ import {
|
||||
ModalClose,
|
||||
Button,
|
||||
} from '@janhq/uikit'
|
||||
import { atom, useAtom } from 'jotai'
|
||||
import { atom, useAtom, useAtomValue } from 'jotai'
|
||||
|
||||
import { errorAtom } from '.'
|
||||
|
||||
export const showChangeFolderErrorAtom = atom(false)
|
||||
|
||||
const ModalErrorSetDestGlobal = () => {
|
||||
const [show, setShow] = useAtom(showChangeFolderErrorAtom)
|
||||
|
||||
const error = useAtomValue(errorAtom)
|
||||
return (
|
||||
<Modal open={show} onOpenChange={setShow}>
|
||||
<ModalPortal />
|
||||
@ -28,6 +30,7 @@ const ModalErrorSetDestGlobal = () => {
|
||||
Oops! Something went wrong. Jan data folder remains the same. Please
|
||||
try again.
|
||||
</p>
|
||||
<p>{error}</p>
|
||||
<ModalFooter>
|
||||
<div className="flex gap-x-2">
|
||||
<ModalClose asChild onClick={() => setShow(false)}>
|
||||
|
||||
@ -2,7 +2,7 @@ import { Fragment, useCallback, useEffect, useState } from 'react'
|
||||
|
||||
import { fs, AppConfiguration } from '@janhq/core'
|
||||
import { Button, Input } from '@janhq/uikit'
|
||||
import { useSetAtom } from 'jotai'
|
||||
import { atom, useSetAtom } from 'jotai'
|
||||
import { PencilIcon, FolderOpenIcon } from 'lucide-react'
|
||||
|
||||
import Loader from '@/containers/Loader'
|
||||
@ -18,6 +18,8 @@ import ModalErrorSetDestGlobal, {
|
||||
|
||||
import ModalSameDirectory, { showSamePathModalAtom } from './ModalSameDirectory'
|
||||
|
||||
export const errorAtom = atom('')
|
||||
|
||||
const DataFolder = () => {
|
||||
const [janDataFolderPath, setJanDataFolderPath] = useState('')
|
||||
const [showLoader, setShowLoader] = useState(false)
|
||||
@ -25,6 +27,7 @@ const DataFolder = () => {
|
||||
const setShowSameDirectory = useSetAtom(showSamePathModalAtom)
|
||||
const setShowChangeFolderError = useSetAtom(showChangeFolderErrorAtom)
|
||||
const [destinationPath, setDestinationPath] = useState(undefined)
|
||||
const setError = useSetAtom(errorAtom)
|
||||
|
||||
useEffect(() => {
|
||||
window.core?.api
|
||||
@ -65,8 +68,10 @@ const DataFolder = () => {
|
||||
setShowLoader(false)
|
||||
}, 1200)
|
||||
await window.core?.api?.relaunch()
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
console.error(`Error: ${e}`)
|
||||
setError(e.message)
|
||||
setShowLoader(false)
|
||||
setShowChangeFolderError(true)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user