mirror of
https://github.com/johndoe6345789/snippet-pastebin.git
synced 2026-04-24 13:34:55 +00:00
Address code review feedback: add error handling, clarify magic numbers, document reload usage
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -246,6 +246,8 @@ export function useSettingsState() {
|
||||
backend: 'indexeddb'
|
||||
})
|
||||
|
||||
// Full page reload is necessary here to reinitialize the database layer
|
||||
// with the new backend after migration from Flask to IndexedDB
|
||||
window.location.reload()
|
||||
|
||||
toast.success(`Successfully migrated ${snippets.length} snippets to IndexedDB`)
|
||||
|
||||
@@ -17,9 +17,18 @@ export function mapRowToObject<T>(row: any[], columns: string[]): T {
|
||||
if (col === 'hasPreview' || col === 'isDefault') {
|
||||
obj[col] = value === 1
|
||||
}
|
||||
// Parse JSON string fields
|
||||
// Parse JSON string fields with error handling
|
||||
else if (col === 'inputParameters') {
|
||||
obj[col] = value ? JSON.parse(value as string) : undefined
|
||||
if (value) {
|
||||
try {
|
||||
obj[col] = JSON.parse(value as string)
|
||||
} catch (error) {
|
||||
console.warn(`Failed to parse JSON for ${col}:`, error)
|
||||
obj[col] = undefined
|
||||
}
|
||||
} else {
|
||||
obj[col] = undefined
|
||||
}
|
||||
}
|
||||
// All other fields pass through as-is
|
||||
else {
|
||||
|
||||
@@ -7,6 +7,11 @@ import type { Monaco } from '@monaco-editor/react'
|
||||
|
||||
/**
|
||||
* TypeScript compiler options for both TypeScript and JavaScript files
|
||||
* Note: Values are enum numbers since Monaco enums aren't directly importable:
|
||||
* - target: 2 = ScriptTarget.Latest
|
||||
* - moduleResolution: 2 = ModuleResolutionKind.NodeJs
|
||||
* - module: 99 = ModuleKind.ESNext
|
||||
* - jsx: 2 = JsxEmit.React
|
||||
*/
|
||||
export const compilerOptions = {
|
||||
target: 2, // ScriptTarget.Latest
|
||||
|
||||
Reference in New Issue
Block a user