Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
use web standard alert for saving changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-mitra committed Aug 13, 2024
1 parent a8ecac6 commit 7a0c9af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 3 additions & 8 deletions packages/editor/src/components/EditorContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { t } from 'i18next'
import { DockLayout, DockMode, LayoutData } from 'rc-dock'
import React, { useEffect, useRef } from 'react'
import { useHotkeys } from 'react-hotkeys-hook'
import Toolbar, { confirmSceneSaveIfModified } from '../components/toolbar/Toolbar'
import Toolbar from '../components/toolbar/Toolbar'
import { cmdOrCtrlString } from '../functions/utils'
import { EditorErrorState } from '../services/EditorErrorServices'
import { EditorState } from '../services/EditorServices'
Expand Down Expand Up @@ -202,17 +202,12 @@ const EditorContainer = () => {

useEffect(() => {
const handleBeforeUnload = async (event: BeforeUnloadEvent) => {
if (!(await confirmSceneSaveIfModified())) {
if (EditorState.isModified()) {
event.preventDefault()
event.returnValue = ''
}
}

window.addEventListener('beforeunload', handleBeforeUnload)

return () => {
window.removeEventListener('beforeunload', handleBeforeUnload)
}
return () => window.removeEventListener('beforeunload', handleBeforeUnload)
}, [])

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ import { uploadToFeathersService } from '@etherealengine/client-core/src/util/up
import { FeatureFlags } from '@etherealengine/common/src/constants/FeatureFlags'
import { clientSettingPath, fileBrowserUploadPath } from '@etherealengine/common/src/schema.type.module'
import { processFileName } from '@etherealengine/common/src/utils/processFileName'
import { getComponent, useComponent, useQuery } from '@etherealengine/ecs'
import { useComponent, useQuery } from '@etherealengine/ecs'
import { ItemTypes, SupportedFileTypes } from '@etherealengine/editor/src/constants/AssetTypes'
import { EditorControlFunctions } from '@etherealengine/editor/src/functions/EditorControlFunctions'
import { addMediaNode } from '@etherealengine/editor/src/functions/addMediaNode'
import { getCursorSpawnPosition } from '@etherealengine/editor/src/functions/screenSpaceFunctions'
import { EditorState } from '@etherealengine/editor/src/services/EditorServices'
import { GLTFComponent } from '@etherealengine/engine/src/gltf/GLTFComponent'
import { ResourcePendingComponent } from '@etherealengine/engine/src/gltf/ResourcePendingComponent'
import { SourceComponent } from '@etherealengine/engine/src/scene/components/SourceComponent'
import useFeatureFlags from '@etherealengine/engine/src/useFeatureFlags'
import { useMutableState } from '@etherealengine/hyperflux'
import { TransformComponent } from '@etherealengine/spatial'
Expand Down Expand Up @@ -124,7 +123,6 @@ const SceneLoadingProgress = ({ rootEntity }) => {
const progress = useComponent(rootEntity, GLTFComponent).progress.value
const loaded = GLTFComponent.useSceneLoaded(rootEntity)
const resourcePendingQuery = useQuery([ResourcePendingComponent])
const root = getComponent(rootEntity, SourceComponent)

if (loaded) return null

Expand Down

0 comments on commit 7a0c9af

Please sign in to comment.