Skip to content

Commit bc049bb

Browse files
committed
Close preferences modal after converting
1 parent 6ad7019 commit bc049bb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/components/PreferencesModal/StorageTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const StorageEditPage = ({ storage }: StorageEditPageProps) => {
147147
<ConvertPouchStorageForm
148148
storageId={storage.id}
149149
storageName={storage.name}
150-
onCancel={foldConvertPouchForm}
150+
closeForm={foldConvertPouchForm}
151151
/>
152152
)}
153153
</>

src/components/organisms/ConvertPouchStorageForm.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ import { join } from 'path'
1414
import { writeFile, prepareDirectory } from '../../lib/electronOnly'
1515
import { entries } from '../../lib/db/utils'
1616
import { useRouter } from '../../lib/router'
17+
import { usePreferences } from '../../lib/preferences'
1718

1819
interface ConvertPouchStorageProps {
1920
storageId: string
2021
storageName: string
21-
onCancel: () => void
22+
closeForm: () => void
2223
}
2324

2425
const ConvertPouchStorage = ({
2526
storageId,
2627
storageName,
27-
onCancel,
28+
closeForm,
2829
}: ConvertPouchStorageProps) => {
2930
const [newStorageName, setNewStorageName] = useState(
3031
`${storageName} - Converted`
3132
)
33+
const { setClosed } = usePreferences()
3234
const [newStorageLocation, setNewStorageLocation] = useState('')
3335
const { storageMap, createStorage } = useDb()
3436
const [errorMessage, setErrorMessage] = useState<string | null>(null)
@@ -93,7 +95,7 @@ const ConvertPouchStorage = ({
9395
type: 'fs',
9496
location: newStorageLocation,
9597
})
96-
98+
setClosed(true)
9799
push(`/app/storages/${newStorage.id}`)
98100
} catch (error) {
99101
console.error(error)
@@ -105,9 +107,10 @@ const ConvertPouchStorage = ({
105107
newStorageLocation,
106108
newStorageName,
107109
createStorage,
110+
setClosed,
108111
push,
109112
])
110-
console.log(errorMessage)
113+
111114
return (
112115
<>
113116
<FormBlockquote variant={errorMessage == null ? 'primary' : 'danger'}>
@@ -131,7 +134,7 @@ const ConvertPouchStorage = ({
131134
<FormPrimaryButton onClick={cloneAndConvertStorage}>
132135
Convert to File System based Storage
133136
</FormPrimaryButton>
134-
<FormSecondaryButton onClick={onCancel}>Cancel</FormSecondaryButton>
137+
<FormSecondaryButton onClick={closeForm}>Cancel</FormSecondaryButton>
135138
</FormGroup>
136139
</>
137140
)

0 commit comments

Comments
 (0)