chore: remove old saved views migration
This commit is contained in:
parent
5451ddf58d
commit
337d289a39
@ -7,42 +7,6 @@ export type ProjectViewSettings = Record<IProject['id'], number>
|
|||||||
|
|
||||||
const SETTINGS_KEY_PROJECT_VIEW = 'projectView'
|
const SETTINGS_KEY_PROJECT_VIEW = 'projectView'
|
||||||
|
|
||||||
// TODO: remove migration when releasing 1.0
|
|
||||||
type ListViewSettings = ProjectViewSettings
|
|
||||||
const SETTINGS_KEY_DEPRECATED_LIST_VIEW = 'listView'
|
|
||||||
function migrateStoredProjectRouteSettings() {
|
|
||||||
try {
|
|
||||||
const listViewSettingsString = localStorage.getItem(SETTINGS_KEY_DEPRECATED_LIST_VIEW)
|
|
||||||
if (listViewSettingsString === null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// A) the first version stored one setting for all lists in a string
|
|
||||||
if (listViewSettingsString.startsWith('list.')) {
|
|
||||||
const projectView = listViewSettingsString.replace('list.', 'project.')
|
|
||||||
|
|
||||||
if (!router.hasRoute(projectView)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return projectView as RouteRecordName
|
|
||||||
}
|
|
||||||
|
|
||||||
// B) the last version used a 'list.' prefix
|
|
||||||
const listViewSettings: ListViewSettings = JSON.parse(listViewSettingsString)
|
|
||||||
|
|
||||||
const projectViewSettingEntries = Object.entries(listViewSettings).map(([id, value]) => {
|
|
||||||
return [id, value.replace('list.', 'project.')]
|
|
||||||
})
|
|
||||||
const projectViewSettings = Object.fromEntries(projectViewSettingEntries)
|
|
||||||
|
|
||||||
localStorage.setItem(SETTINGS_KEY_PROJECT_VIEW, JSON.stringify(projectViewSettings))
|
|
||||||
} catch(e) {
|
|
||||||
//
|
|
||||||
} finally {
|
|
||||||
localStorage.removeItem(SETTINGS_KEY_DEPRECATED_LIST_VIEW)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the current project view to local storage
|
* Save the current project view to local storage
|
||||||
*/
|
*/
|
||||||
@ -68,13 +32,6 @@ export function saveProjectView(projectId: IProject['id'], viewId: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getProjectView = (projectId: IProject['id']) => {
|
export const getProjectView = (projectId: IProject['id']) => {
|
||||||
// TODO: remove migration when releasing 1.0
|
|
||||||
const migratedProjectView = migrateStoredProjectRouteSettings()
|
|
||||||
|
|
||||||
if (migratedProjectView !== undefined && router.hasRoute(migratedProjectView)) {
|
|
||||||
return migratedProjectView
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const projectViewSettingsString = localStorage.getItem(SETTINGS_KEY_PROJECT_VIEW)
|
const projectViewSettingsString = localStorage.getItem(SETTINGS_KEY_PROJECT_VIEW)
|
||||||
if (!projectViewSettingsString) {
|
if (!projectViewSettingsString) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user