mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-10-06 22:32:41 +07:00
chore: Disable the unload page warning
This commit is contained in:
@@ -78,28 +78,6 @@ const useVideoChapters = () => {
|
|||||||
}
|
}
|
||||||
}, [history, historyPosition]);
|
}, [history, historyPosition]);
|
||||||
|
|
||||||
// Set up page unload warning
|
|
||||||
useEffect(() => {
|
|
||||||
// Event handler for beforeunload
|
|
||||||
const handleBeforeUnload = (e: BeforeUnloadEvent) => {
|
|
||||||
if (hasUnsavedChanges) {
|
|
||||||
// Standard way of showing a confirmation dialog before leaving
|
|
||||||
const message = 'Your edits will get lost if you leave the page. Do you want to continue?';
|
|
||||||
e.preventDefault();
|
|
||||||
e.returnValue = message; // Chrome requires returnValue to be set
|
|
||||||
return message; // For other browsers
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add event listener
|
|
||||||
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
||||||
|
|
||||||
// Clean up
|
|
||||||
return () => {
|
|
||||||
window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
||||||
};
|
|
||||||
}, [hasUnsavedChanges]);
|
|
||||||
|
|
||||||
// Initialize video event listeners
|
// Initialize video event listeners
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const video = videoRef.current;
|
const video = videoRef.current;
|
||||||
@@ -737,7 +715,7 @@ const useVideoChapters = () => {
|
|||||||
if (typeof window !== 'undefined' && window.lastSeekedPosition > 0) {
|
if (typeof window !== 'undefined' && window.lastSeekedPosition > 0) {
|
||||||
// Only seek if the position is significantly different
|
// Only seek if the position is significantly different
|
||||||
if (Math.abs(video.currentTime - window.lastSeekedPosition) > 0.1) {
|
if (Math.abs(video.currentTime - window.lastSeekedPosition) > 0.1) {
|
||||||
console.log('handlePlay: Using lastSeekedPosition', window.lastSeekedPosition);
|
logger.debug('handlePlay: Using lastSeekedPosition', window.lastSeekedPosition);
|
||||||
video.currentTime = window.lastSeekedPosition;
|
video.currentTime = window.lastSeekedPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,28 +63,6 @@ const useVideoTrimmer = () => {
|
|||||||
}
|
}
|
||||||
}, [history, historyPosition]);
|
}, [history, historyPosition]);
|
||||||
|
|
||||||
// Set up page unload warning
|
|
||||||
useEffect(() => {
|
|
||||||
// Event handler for beforeunload
|
|
||||||
const handleBeforeUnload = (e: BeforeUnloadEvent) => {
|
|
||||||
if (hasUnsavedChanges) {
|
|
||||||
// Standard way of showing a confirmation dialog before leaving
|
|
||||||
const message = 'Your edits will get lost if you leave the page. Do you want to continue?';
|
|
||||||
e.preventDefault();
|
|
||||||
e.returnValue = message; // Chrome requires returnValue to be set
|
|
||||||
return message; // For other browsers
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add event listener
|
|
||||||
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
||||||
|
|
||||||
// Clean up
|
|
||||||
return () => {
|
|
||||||
window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
||||||
};
|
|
||||||
}, [hasUnsavedChanges]);
|
|
||||||
|
|
||||||
// Initialize video event listeners
|
// Initialize video event listeners
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const video = videoRef.current;
|
const video = videoRef.current;
|
||||||
@@ -665,7 +643,7 @@ const useVideoTrimmer = () => {
|
|||||||
if (typeof window !== 'undefined' && window.lastSeekedPosition > 0) {
|
if (typeof window !== 'undefined' && window.lastSeekedPosition > 0) {
|
||||||
// Only seek if the position is significantly different
|
// Only seek if the position is significantly different
|
||||||
if (Math.abs(video.currentTime - window.lastSeekedPosition) > 0.1) {
|
if (Math.abs(video.currentTime - window.lastSeekedPosition) > 0.1) {
|
||||||
console.log('handlePlay: Using lastSeekedPosition', window.lastSeekedPosition);
|
logger.debug('handlePlay: Using lastSeekedPosition', window.lastSeekedPosition);
|
||||||
video.currentTime = window.lastSeekedPosition;
|
video.currentTime = window.lastSeekedPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user