2020-05-22 17:28:26 +02:00
|
|
|
|
|
|
|
export const saveListView = (listId, routeName) => {
|
2020-05-29 16:33:57 +02:00
|
|
|
const savedListView = localStorage.getItem('listView')
|
|
|
|
let savedListViewJson = false
|
|
|
|
if (savedListView !== null) {
|
|
|
|
savedListViewJson = JSON.parse(savedListView)
|
|
|
|
}
|
2020-05-22 17:28:26 +02:00
|
|
|
|
|
|
|
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]
|
|
|
|
}
|