This commit is contained in:
kolaente 2021-07-19 17:46:05 +02:00
parent 0f5dea1029
commit d3517a10c6
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 2 additions and 31 deletions

View File

@ -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": {

View File

@ -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))
}