-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement cookie-based caching for featured listings (#561)
* implement cookie-based caching for featured listings * Fix type errors * Updated to use localStorage
- Loading branch information
Showing
4 changed files
with
41 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export interface FeaturedListing { | ||
id: string; | ||
username: string; | ||
slug: string | null; | ||
name: string; | ||
} | ||
|
||
export const FEATURED_LISTINGS_KEY = "featured_listings"; | ||
|
||
export const getFeaturedListingsFromStorage = (): FeaturedListing[] => { | ||
try { | ||
const stored = localStorage.getItem(FEATURED_LISTINGS_KEY); | ||
return stored ? JSON.parse(stored) : []; | ||
} catch (error) { | ||
console.error("Error parsing featured listings from storage:", error); | ||
return []; | ||
} | ||
}; | ||
|
||
export const setFeaturedListingsStorage = (listings: FeaturedListing[]) => { | ||
try { | ||
localStorage.setItem(FEATURED_LISTINGS_KEY, JSON.stringify(listings)); | ||
} catch (error) { | ||
console.error("Error storing featured listings:", error); | ||
} | ||
}; |