fix: ensure localStorage keys are properly checked before removal in proceedToNext function
This commit is contained in:
@@ -150,11 +150,15 @@ const proceedToNext = () => {
|
||||
const keysToRemove = []
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i)
|
||||
if (key && key.startsWith('photobooth-1x4-') || key.startsWith('photobooth-2x2-')) {
|
||||
if (key && (key.startsWith('photobooth-1x4-') || key.startsWith('photobooth-2x2-'))) {
|
||||
keysToRemove.push(key)
|
||||
}
|
||||
}
|
||||
keysToRemove.forEach(key => localStorage.removeItem(key))
|
||||
keysToRemove.forEach(key => {
|
||||
if (key !== null) {
|
||||
localStorage.removeItem(key)
|
||||
}
|
||||
})
|
||||
|
||||
// เก็บรูปภาพไว้ใน localStorage
|
||||
localStorage.setItem('photobooth-photos', JSON.stringify(photos.value))
|
||||
|
||||
Reference in New Issue
Block a user