Skip to content

Commit

Permalink
fix: remove localstorage legacy migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
pionxzh committed Dec 24, 2023
1 parent b65515c commit 00ad390
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/constants.ts
Expand Up @@ -7,7 +7,6 @@ const API_MAPPING: Record<string, string> = {
export const baseUrl = new URL(location.href).origin
export const apiUrl = API_MAPPING[baseUrl]

export const LEGACY_KEY_FILENAME_FORMAT = 'exporter-format'
export const KEY_LANGUAGE = 'exporter:language'
export const KEY_FILENAME_FORMAT = 'exporter:filename_format'
export const KEY_OFFICIAL_JSON_FORMAT = 'exporter:official_json_format'
Expand Down
21 changes: 0 additions & 21 deletions src/main.tsx
@@ -1,34 +1,13 @@
import { render } from 'preact'
import sentinel from 'sentinel-js'
import { GM_deleteValue, GM_getValue, GM_setValue } from 'vite-plugin-monkey/dist/client'
import { fetchConversation, processConversation } from './api'
import { KEY_FILENAME_FORMAT, LEGACY_KEY_FILENAME_FORMAT } from './constants'
import { getChatIdFromUrl, getConversationChoice, isSharePage } from './page'
import { Menu } from './ui/Menu'
import { onloadSafe } from './utils/utils'

import './i18n'
import './styles/missing-tailwind.css'

/**
* Migrate legacy filename format
*/
try {
const legacyFormat = GM_getValue?.(LEGACY_KEY_FILENAME_FORMAT, '')
const localLegacyFormat = localStorage.getItem(LEGACY_KEY_FILENAME_FORMAT)
if (legacyFormat) {
GM_deleteValue?.(LEGACY_KEY_FILENAME_FORMAT)
GM_setValue?.(KEY_FILENAME_FORMAT, JSON.stringify(legacyFormat))
}
else if (localLegacyFormat) {
localStorage.removeItem(LEGACY_KEY_FILENAME_FORMAT)
localStorage.setItem(KEY_FILENAME_FORMAT, JSON.stringify(localLegacyFormat))
}
}
catch (error) {
console.error('Failed to migrate legacy filename format', error)
}

main()

function main() {
Expand Down

0 comments on commit 00ad390

Please sign in to comment.