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