✨ Store location last seen date to check for New label
Stores the last location's page seeing date in localStorage to hide the Location's new label in list, on top of the date limit
This commit is contained in:
@@ -2,4 +2,23 @@ import { writable, type Writable } from 'svelte/store'
|
||||
|
||||
export const pageLoading: Writable<boolean> = writable(false)
|
||||
export const previousPage: Writable<string> = writable('')
|
||||
export const smoothScroll: Writable<any> = writable(null)
|
||||
export const smoothScroll: Writable<any> = writable(null)
|
||||
|
||||
|
||||
/**
|
||||
* New locations tracking
|
||||
*/
|
||||
export const seenLocations: Writable<string> = writable('{}')
|
||||
|
||||
// Define local storage from store
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
const seen = localStorage.getItem('seenLocations')
|
||||
if (seen) {
|
||||
const parsedValue = JSON.parse(seen)
|
||||
seenLocations.set(JSON.stringify(parsedValue))
|
||||
}
|
||||
seenLocations.subscribe(value => {
|
||||
const parsedValue = JSON.parse(value)
|
||||
localStorage.setItem('seenLocations', JSON.stringify(parsedValue))
|
||||
})
|
||||
}
|
||||
@@ -18,9 +18,10 @@ export const cartId: Writable<string> = writable(null)
|
||||
|
||||
// Write to localStorage when changing cartId
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
if (localStorage.getItem('cartId')) {
|
||||
// console.log('existant', localStorage.getItem('cartId'))
|
||||
cartId.set(localStorage.getItem('cartId'))
|
||||
const cartId = localStorage.getItem('cartId')
|
||||
if (cartId) {
|
||||
cartId.set(cartId)
|
||||
// console.log('existing cart:', cartId)
|
||||
}
|
||||
cartId.subscribe(value => localStorage.setItem('cartId', value))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user