Skip to content

Commit

Permalink
fix(price create form): move selected location to the top of recent h…
Browse files Browse the repository at this point in the history
…istory. ref #52
  • Loading branch information
raphodn committed Dec 24, 2023
1 parent 3e3fb1e commit e6465eb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ function setValueToLocalStorageItem(itemKey, value) {

function addObjectToLocalStorageItemArray(itemKey, obj, unshift=false, avoidDuplicates=true) {
let itemJSON = getParsedLocalStorageItem(itemKey, [])
var existingItem = itemJSON.find(item => JSON.stringify(item) === JSON.stringify(obj))
if (avoidDuplicates && existingItem) {
return
// look for duplicate
var duplicateItem = itemJSON.findIndex(item => JSON.stringify(item) === JSON.stringify(obj))
if (avoidDuplicates && duplicateItem >= 0) {
itemJSON.splice(duplicateItem, 1)
}
// add obj to array
if (unshift) {
Expand Down

0 comments on commit e6465eb

Please sign in to comment.