This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
store search-result fields in localStorage + add reset option
- Loading branch information
1 parent
968c98f
commit 6c3368b
Showing
4 changed files
with
77 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const FIELD_STORAGE_KEY = 'search-result-fields' | ||
|
||
function getStoredFields () { | ||
try { | ||
const stored = localStorage.getItem(FIELD_STORAGE_KEY) | ||
|
||
if (!stored) | ||
return [] | ||
|
||
return JSON.parse(stored) | ||
} catch (e) { | ||
return [] | ||
} | ||
} | ||
|
||
function setStoredFields (value) { | ||
localStorage.setItem(FIELD_STORAGE_KEY, JSON.stringify(value)) | ||
} | ||
|
||
export default { | ||
get: getStoredFields, | ||
set: setStoredFields, | ||
} |
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