@unitedstatespowersquadrons/components 1.4.0-2 → 1.4.0-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,9 +15,7 @@ interface BroadcastPayload {
15
15
  }
16
16
 
17
17
  const sortBroadcastsFirst = (toasts: readonly ToastProps[]): ToastProps[] => (
18
- [...toasts].sort((a, b) => (
19
- Number(b.kind === "broadcast") - Number(a.kind === "broadcast")
20
- ))
18
+ [...toasts].sort((a, b) => Number(b.kind === "broadcast") - Number(a.kind === "broadcast"))
21
19
  );
22
20
 
23
21
  const GlobalToasts = ({ allowedDomains }: Props) => {
@@ -29,12 +27,8 @@ const GlobalToasts = ({ allowedDomains }: Props) => {
29
27
  { channel: "BroadcastToastChannel" },
30
28
  {
31
29
  received: (data: BroadcastPayload) => {
32
- if (data.toasts) {
33
- data.toasts.forEach(t => toastStore.add({ ...t, kind: "broadcast" }));
34
- }
35
- if (typeof data.dismissToast === "number") {
36
- toastStore.remove(data.dismissToast);
37
- }
30
+ if (data.toasts) data.toasts.forEach(t => toastStore.add({ kind: "broadcast", ...t }));
31
+ if (typeof data.dismissToast === "number") toastStore.remove(data.dismissToast);
38
32
  },
39
33
  }
40
34
  );
@@ -42,17 +36,13 @@ const GlobalToasts = ({ allowedDomains }: Props) => {
42
36
 
43
37
  return () => {
44
38
  sub.unsubscribe();
45
- if (broadcastSubscriptionRef.current === sub) {
46
- broadcastSubscriptionRef.current = null;
47
- }
39
+ if (broadcastSubscriptionRef.current === sub) broadcastSubscriptionRef.current = null;
48
40
  };
49
41
  }, []);
50
42
 
51
43
  const sorted = sortBroadcastsFirst(toasts);
52
44
 
53
- return allowedDomains
54
- ? <Toasts allowedDomains={allowedDomains} dismiss={dismissToastGlobal} toasts={sorted} />
55
- : <Toasts dismiss={dismissToastGlobal} toasts={sorted} />;
45
+ return <Toasts allowedDomains={allowedDomains} dismiss={dismissToastGlobal} toasts={sorted} />;
56
46
  };
57
47
 
58
48
  export default GlobalToasts;
package/Toasts/Toasts.tsx CHANGED
@@ -7,7 +7,7 @@ import { DismissFunc, ToastProps, ToastRemoveAppAction } from "./types";
7
7
  import { DispatchFunc } from "../";
8
8
 
9
9
  interface BaseProps {
10
- allowedDomains?: string[];
10
+ allowedDomains?: string[] | undefined;
11
11
  toasts?: ToastProps[];
12
12
  }
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unitedstatespowersquadrons/components",
3
- "version": "1.4.0-2",
3
+ "version": "1.4.0-3",
4
4
  "description": "USPS shared React components library",
5
5
  "main": "index.tsx",
6
6
  "scripts": {