e0be77d88f
Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/397 Co-authored-by: konrad <konrad@kola-entertainments.de> Co-committed-by: konrad <konrad@kola-entertainments.de>
39 lines
No EOL
881 B
JavaScript
39 lines
No EOL
881 B
JavaScript
export const saveListView = (listId, routeName) => {
|
|
if(routeName.includes('settings.')) {
|
|
return
|
|
}
|
|
|
|
const savedListView = localStorage.getItem('listView')
|
|
let savedListViewJson = false
|
|
if (savedListView !== null) {
|
|
savedListViewJson = JSON.parse(savedListView)
|
|
}
|
|
|
|
let listView = {}
|
|
if (savedListViewJson) {
|
|
listView = savedListViewJson
|
|
}
|
|
|
|
listView[listId] = routeName
|
|
localStorage.setItem('listView', JSON.stringify(listView))
|
|
}
|
|
|
|
export const getListView = listId => {
|
|
// Remove old stored settings
|
|
const savedListView = localStorage.getItem('listView')
|
|
if (savedListView !== null && savedListView.startsWith('list.')) {
|
|
localStorage.removeItem('listView')
|
|
}
|
|
|
|
if (!savedListView) {
|
|
return 'list.list'
|
|
}
|
|
|
|
const savedListViewJson = JSON.parse(savedListView)
|
|
|
|
if (!savedListViewJson[listId]) {
|
|
return 'list.list'
|
|
}
|
|
|
|
return savedListViewJson[listId]
|
|
} |