forked from ealush/emoji-picker-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from AdmitHub/persist-skin-tone
Persist skin tone
- Loading branch information
Showing
4 changed files
with
41 additions
and
10 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,25 @@ | ||
import { SkinTones } from '../types/exposedTypes'; | ||
|
||
const SKINTONE_LS_KEY = 'epr_skin_tone'; | ||
|
||
|
||
export function getSkinTone(): SkinTones { | ||
try { | ||
if (!window?.localStorage) { | ||
return SkinTones.NEUTRAL; | ||
} | ||
|
||
return JSON.parse(window?.localStorage.getItem(SKINTONE_LS_KEY) ?? SkinTones.NEUTRAL) | ||
} catch { | ||
return SkinTones.NEUTRAL; | ||
} | ||
} | ||
|
||
export function setSkinTone(skinTone: SkinTones) { | ||
try { | ||
window?.localStorage.setItem(SKINTONE_LS_KEY, JSON.stringify(skinTone)); | ||
// Prevents the change from being seen immediately. | ||
} catch { | ||
// ignore | ||
} | ||
} |