• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / fx-private-relay / 85cda637-2ac9-4d08-9727-ee8e8a702875

06 Sep 2024 09:48PM CUT coverage: 85.506%. First build
85cda637-2ac9-4d08-9727-ee8e8a702875

push

circleci

jwhitlock
Handle Twilio errors when relaying messages

When a Relay user replies 'STOP', they are unsubscribed from Twilio and
we can't send them any more messages.

When a contact replies 'STOP', the Relay user can't reply to them
anymore.

There are other errors, but those haven't happened to us yet. Log as
errors.

4111 of 5264 branches covered (78.1%)

Branch coverage included in aggregate %.

133 of 134 new or added lines in 2 files covered. (99.25%)

16130 of 18408 relevant lines covered (87.62%)

10.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/frontend/src/components/waitlist/CountryPicker.tsx
1
import { SelectHTMLAttributes, useEffect, useState } from "react";
×
2
import { getLocale } from "../../functions/getLocale";
×
3
import { useL10n } from "../../hooks/l10n";
×
4

5
type LocaleDisplayNames = Record<string, string>;
6
type Territories = {
7
  main: Record<
8
    string,
9
    {
10
      localeDisplayNames: {
11
        territories: LocaleDisplayNames;
12
      };
13
    }
14
  >;
15
};
16
export type Props = SelectHTMLAttributes<HTMLSelectElement>;
17
export const CountryPicker = (props: Props) => {
×
18
  const l10n = useL10n();
×
19
  const currentLocale = getLocale(l10n);
×
20
  const [localeDisplayNames, setLocaleDisplayNames] =
21
    useState<LocaleDisplayNames>();
×
22

23
  useEffect(() => {
×
24
    importTerritories(currentLocale).then((localeDisplayNames) => {
×
25
      setLocaleDisplayNames(localeDisplayNames);
×
26
    });
27
  }, [currentLocale]);
28

29
  const options = Object.entries(localeDisplayNames ?? {})
×
30
    // cldr-localenames-modern also includes names of continents,
31
    // whose territory codes consist of numbers.
32
    // (See e.g. node_modules/cldr-localenames-modern/main/en/territories.json.)
33
    // Since we're only interested in countries, filter those out:
34
    .filter(
35
      ([code]) =>
36
        !["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].some((nr) =>
×
37
          code.includes(nr),
×
38
        ),
39
    )
40
    .sort(([_codeA, nameA], [_codeB, nameB]) => nameA.localeCompare(nameB))
×
41
    .map(([code, name]) => (
42
      <option key={code} value={code}>
×
43
        {name}
44
      </option>
45
    ));
46

47
  return <select {...props}>{options}</select>;
48
};
49

50
async function importTerritories(locale: string): Promise<LocaleDisplayNames> {
51
  try {
×
52
    const territories: Territories = await import(
×
53
      `cldr-localenames-modern/main/${locale}/territories.json`
×
54
    );
55
    return territories.main[locale].localeDisplayNames.territories;
×
56
  } catch (_e) {
57
    try {
×
58
      // cldr-localenames-modern doesn't include suffixed locale codes for
59
      // locales in their main territory (i.e. it only has `es`, not `es-ES`, or
60
      // `nl` but not `nl-NL`, or `sv` but not `sv-SE`), so try loading a
61
      // truncated version if the full version was not found:
62
      const truncatedLocale = locale.split("-")[0];
×
63
      const territories: Territories = await import(
×
64
        `cldr-localenames-modern/main/${truncatedLocale}/territories.json`
×
65
      );
66
      return territories.main[truncatedLocale].localeDisplayNames.territories;
×
67
    } catch (_e) {
68
      const territoriesEn = await import(
×
69
        "cldr-localenames-modern/main/en/territories.json"
70
      );
71
      return territoriesEn.main.en.localeDisplayNames.territories;
×
72
    }
73
  }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc