Cleanup
This commit is contained in:
parent
0f5dea1029
commit
d3517a10c6
|
@ -5,11 +5,11 @@
|
|||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build --modern",
|
||||
"test:unit": "jest",
|
||||
"lint": "vue-cli-service lint --ignore-pattern '*.test.*'",
|
||||
"build:report": "vue-cli-service build --report",
|
||||
"lint": "vue-cli-service lint --ignore-pattern '*.test.*'",
|
||||
"cypress:open": "cypress open",
|
||||
"serve:dist": "node scripts/serve-dist.js",
|
||||
"test:unit": "jest",
|
||||
"test:frontend": "cypress run"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
export const getHistory = () => {
|
||||
const savedHistory = localStorage.getItem('listHistory')
|
||||
if (savedHistory === null) {
|
||||
return []
|
||||
}
|
||||
|
||||
return JSON.parse(savedHistory)
|
||||
}
|
||||
|
||||
export function saveListToHistory(list) {
|
||||
const history = getHistory()
|
||||
|
||||
list.id = parseInt(list.id)
|
||||
|
||||
// Remove the element if it already exists in history, preventing duplicates and essentially moving it to the beginning
|
||||
for (const i in history) {
|
||||
if (history[i].id === list.id) {
|
||||
history.splice(i, 1)
|
||||
}
|
||||
}
|
||||
|
||||
// Add the new list to the beginning of the list
|
||||
history.unshift(list)
|
||||
|
||||
if (history.length > 5) {
|
||||
history.pop()
|
||||
}
|
||||
localStorage.setItem('listHistory', JSON.stringify(history))
|
||||
}
|
Reference in New Issue