mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 01:11:13 -05:00
Improve form validation and image handling for entities
Refactor validation logic for 'founded_year' in multiple form components, enhance image cleanup in `EntityMultiImageUploader`, update `useEntityVersions` to prevent race conditions, improve error handling for recent searches in `useSearch`, refine rate limiting logic in `detect-location` Supabase function, and update CORS configuration for `upload-image` Supabase function. Replit-Commit-Author: Agent Replit-Commit-Session-Id: b9af4867-23a7-43cc-baeb-4a97f66b4150 Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
@@ -58,14 +58,24 @@ export function useSearch(options: UseSearchOptions = {}) {
|
||||
try {
|
||||
const stored = localStorage.getItem('thrillwiki_recent_searches');
|
||||
if (stored) {
|
||||
const parsed = JSON.parse(stored);
|
||||
if (Array.isArray(parsed)) {
|
||||
setRecentSearches(parsed);
|
||||
try {
|
||||
const parsed = JSON.parse(stored);
|
||||
if (Array.isArray(parsed)) {
|
||||
setRecentSearches(parsed);
|
||||
} else {
|
||||
// Invalid format, clear it
|
||||
console.warn('Recent searches data is not an array, clearing');
|
||||
localStorage.removeItem('thrillwiki_recent_searches');
|
||||
}
|
||||
} catch (parseError) {
|
||||
// JSON parse failed, data is corrupted
|
||||
console.error('Failed to parse recent searches from localStorage:', parseError);
|
||||
localStorage.removeItem('thrillwiki_recent_searches');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to parse recent searches from localStorage:', error);
|
||||
localStorage.removeItem('thrillwiki_recent_searches');
|
||||
// localStorage access failed
|
||||
console.error('Error accessing localStorage:', error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user