ChemPal Documentation - v1.6.0
    Preparing search index...

    Function getUserCountryName

    • Reads the user's selected country (full name) from persisted user settings. The country field is kept in sync with the location code by the settings reducer, so consumers that need a full country name can read it directly.

      Returns Promise<undefined | string>

      The stored country name, or undefined if unset/invalid

      await getUserCountryName() // "United States"
      
      export async function getUserCountryName(): Promise<string | undefined> {
      const stored = await cstorage.local.get([CACHE.USER_SETTINGS]);
      const settings: unknown = stored[CACHE.USER_SETTINGS];
      if (typeof settings !== 'object' || settings === null) {
      return undefined;
      }
      const country = (settings as Record<string, unknown>).country;
      return typeof country === 'string' ? country : undefined;
      }