helpers.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { LS_KEYS, getData, setData } from '.';
  2. export const getToken = (): string => {
  3. const token = getData(LS_KEYS.USER)?.token;
  4. return token;
  5. };
  6. export const getUserID = () => getData(LS_KEYS.USER)?.id;
  7. export const isFirstLogin = () =>
  8. getData(LS_KEYS.IS_FIRST_LOGIN)?.status ?? false;
  9. export function setIsFirstLogin(status: boolean) {
  10. setData(LS_KEYS.IS_FIRST_LOGIN, { status });
  11. }
  12. export const justSignedUp = () =>
  13. getData(LS_KEYS.JUST_SIGNED_UP)?.status ?? false;
  14. export function setJustSignedUp(status: boolean) {
  15. setData(LS_KEYS.JUST_SIGNED_UP, { status });
  16. }
  17. export function getLivePhotoInfoShownCount() {
  18. return getData(LS_KEYS.LIVE_PHOTO_INFO_SHOWN_COUNT)?.count ?? 0;
  19. }
  20. export function setLivePhotoInfoShownCount(count: boolean) {
  21. setData(LS_KEYS.LIVE_PHOTO_INFO_SHOWN_COUNT, { count });
  22. }
  23. export function getUserLocaleString(): string {
  24. return getData(LS_KEYS.LOCALE)?.value;
  25. }
  26. export function getLocalMapEnabled(): boolean {
  27. return getData(LS_KEYS.MAP_ENABLED)?.value ?? false;
  28. }
  29. export function setLocalMapEnabled(value: boolean) {
  30. setData(LS_KEYS.MAP_ENABLED, { value });
  31. }
  32. export function getHasOptedOutOfCrashReports(): boolean {
  33. return getData(LS_KEYS.OPT_OUT_OF_CRASH_REPORTS)?.value ?? false;
  34. }
  35. export function getLocalSentryUserID() {
  36. return getData(LS_KEYS.AnonymizedUserID)?.id;
  37. }
  38. export function setLocalSentryUserID(id: string) {
  39. setData(LS_KEYS.AnonymizedUserID, { id });
  40. }
  41. export function getLocalReferralSource() {
  42. return getData(LS_KEYS.REFERRAL_SOURCE)?.source;
  43. }
  44. export function setLocalReferralSource(source: string) {
  45. setData(LS_KEYS.REFERRAL_SOURCE, { source });
  46. }