helpers.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 getLocalMapEnabled(): boolean {
  24. return getData(LS_KEYS.MAP_ENABLED)?.value ?? false;
  25. }
  26. export function setLocalMapEnabled(value: boolean) {
  27. setData(LS_KEYS.MAP_ENABLED, { value });
  28. }
  29. export function getHasOptedOutOfCrashReports(): boolean {
  30. return getData(LS_KEYS.OPT_OUT_OF_CRASH_REPORTS)?.value ?? false;
  31. }
  32. export function getLocalSentryUserID() {
  33. return getData(LS_KEYS.AnonymizedUserID)?.id;
  34. }
  35. export function setLocalSentryUserID(id: string) {
  36. setData(LS_KEYS.AnonymizedUserID, { id });
  37. }
  38. export function getLocalReferralSource() {
  39. return getData(LS_KEYS.REFERRAL_SOURCE)?.source;
  40. }
  41. export function setLocalReferralSource(source: string) {
  42. setData(LS_KEYS.REFERRAL_SOURCE, { source });
  43. }