mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #34750 from overleaf/dp-cleanup-reference-settings-migration
[web] Remove reference manager settings migration code GitOrigin-RevId: 1062e1f08a6e6d4547f48c965c342d2ac15e9a4f
This commit is contained in:
@@ -6,13 +6,9 @@ import {
|
||||
SetStateAction,
|
||||
FC,
|
||||
useState,
|
||||
useEffect,
|
||||
} from 'react'
|
||||
import { UserSettings } from '../../../../types/user-settings'
|
||||
import getMeta from '@/utils/meta'
|
||||
import customLocalStorage from '@/infrastructure/local-storage'
|
||||
import { getLegacyWriteAndCiteMigration } from '../utils/write-and-cite-settings-migration'
|
||||
import { saveUserSettings } from '@/features/editor-left-menu/utils/api'
|
||||
|
||||
export const defaultSettings: UserSettings = {
|
||||
pdfViewer: 'pdfjs',
|
||||
@@ -70,31 +66,6 @@ export const UserSettingsProvider: FC<React.PropsWithChildren> = ({
|
||||
() => getMeta('ol-userSettings') || defaultSettings
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
const { patch, keysToRemove } = getLegacyWriteAndCiteMigration(userSettings)
|
||||
if (Object.keys(patch).length === 0) {
|
||||
keysToRemove.forEach(customLocalStorage.removeItem)
|
||||
return
|
||||
}
|
||||
|
||||
Promise.all(
|
||||
Object.entries(patch).map(([key, value]) =>
|
||||
saveUserSettings(
|
||||
key as keyof Pick<UserSettings, 'mendeley' | 'zotero' | 'papers'>,
|
||||
value
|
||||
)
|
||||
)
|
||||
).then(() => {
|
||||
setUserSettings(currentSettings => ({
|
||||
...currentSettings,
|
||||
...patch,
|
||||
}))
|
||||
keysToRemove.forEach(customLocalStorage.removeItem)
|
||||
})
|
||||
// Only run once when the provider mounts
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
const value = useMemo<UserSettingsContextValue>(
|
||||
() => ({
|
||||
userSettings,
|
||||
|
||||
Reference in New Issue
Block a user