mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
add
This commit is contained in:
@@ -6,7 +6,7 @@ function prefix() {
|
||||
return environment.version.lastCommitNumber + environment.id+"-";
|
||||
}
|
||||
|
||||
export function GET({key, localStorage, instance}) {
|
||||
export function GET({key, instance}) {
|
||||
if(environment.storageProduction) {
|
||||
|
||||
try {
|
||||
@@ -26,7 +26,8 @@ export function GET({key, localStorage, instance}) {
|
||||
}
|
||||
|
||||
} else {
|
||||
const restoredData = JSON.parse(localStorage.getItem(prefix() + key))
|
||||
const newKey = prefix() + key
|
||||
const restoredData = JSON.parse(localStorage.getItem(newKey))
|
||||
Object.assign(instance, restoredData);
|
||||
|
||||
return restoredData
|
||||
@@ -34,7 +35,7 @@ export function GET({key, localStorage, instance}) {
|
||||
|
||||
}
|
||||
|
||||
export function SAVE({key, localStorage, instance, dataToSave}) {
|
||||
export function SAVE({key, instance, dataToSave}) {
|
||||
if(environment.storageProduction) {
|
||||
const newKey = prefix() + SHA1(key).toString()
|
||||
const stringifyData = JSON.stringify(dataToSave)
|
||||
@@ -45,16 +46,19 @@ export function SAVE({key, localStorage, instance, dataToSave}) {
|
||||
|
||||
} else {
|
||||
const stringifyData = JSON.stringify(dataToSave)
|
||||
localStorage.setItem(prefix() + key, stringifyData)
|
||||
const newKey = prefix() + key
|
||||
|
||||
localStorage.setItem(newKey, stringifyData)
|
||||
}
|
||||
}
|
||||
|
||||
export function DELETE({key, localStorage, instance}) {
|
||||
export function DELETE({key, instance}) {
|
||||
if(environment.storageProduction) {
|
||||
const newKey = prefix() + SHA1(key).toString()
|
||||
localStorage.removeItem(newKey)
|
||||
|
||||
} else {
|
||||
localStorage.removeItem(prefix() + key)
|
||||
const newKey = prefix() + key
|
||||
localStorage.removeItem(newKey)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user