Skip to content

Commit

Permalink
display notification on save
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Aug 26, 2024
1 parent ffc9a0c commit 69cfb89
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/react/PauseScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Button from './Button'
import Screen from './Screen'
import styles from './PauseScreen.module.css'
import { DiscordButton } from './DiscordButton'
import { showNotification } from './NotificationProvider'

export const saveToBrowserMemory = async () => {
setLoadingScreenStatus('Saving world')
Expand All @@ -33,10 +34,12 @@ export const saveToBrowserMemory = async () => {
const allRootPaths = [...usedServerPathsV1]
const allFilesToCopy = [] as string[]
for (const dirBase of allRootPaths) {
// eslint-disable-next-line no-await-in-loop
if (dirBase.includes('.') && await fileExistsAsyncOptimized(join(worldFolder, dirBase))) {
allFilesToCopy.push(dirBase)
continue
}
// eslint-disable-next-line no-await-in-loop
let res = await collectFilesToCopy(join(worldFolder, dirBase), true)
if (dirBase === 'region') {
res = res.filter(x => x.endsWith('.mca'))
Expand Down Expand Up @@ -133,7 +136,10 @@ export default () => {
}
const action = await showOptionsModal('World actions...', ['Save to browser memory'])
if (action === 'Save to browser memory') {
await saveToBrowserMemory()
const path = await saveToBrowserMemory()
if (!path) return
const saveName = path.split('/').at(-1)
showNotification(`World saved to ${saveName}`, 'Load it to keep your progress!')
// fsState.inMemorySave = true
// fsState.syncFs = false
// fsState.isReadonly = false
Expand Down

0 comments on commit 69cfb89

Please sign in to comment.