@applicaster/zapp-react-native-ui-components 15.0.0-alpha.6222113329 → 15.0.0-alpha.6685355529

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.
@@ -277,7 +277,6 @@ const PlayerContainerComponent = (props: Props) => {
277
277
  const { isRestricted } = useRestrictMobilePlayback({
278
278
  player,
279
279
  entry: item,
280
- pluginConfiguration,
281
280
  close,
282
281
  });
283
282
 
@@ -1,28 +1,49 @@
1
1
  import { Player } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/player";
2
2
  import NetInfo from "@react-native-community/netinfo";
3
3
 
4
- import { useEffect, useMemo, useRef, useState } from "react";
4
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { showAlertDialog } from "@applicaster/zapp-react-native-utils/alertUtils";
6
6
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
7
7
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
8
8
  import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager";
9
+ import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
10
+ import { getLocalizations } from "@applicaster/zapp-react-native-utils/localizationUtils";
9
11
  import { log_info } from "./logger";
10
12
 
11
13
  type RestrictMobilePlaybackProps = {
12
14
  player?: Player;
13
15
  entry?: ZappEntry;
14
- pluginConfiguration?: Record<string, string>;
15
16
  close: () => void;
16
17
  };
17
18
 
18
19
  export const useRestrictMobilePlayback = ({
19
20
  player,
20
21
  entry,
21
- pluginConfiguration,
22
22
  close,
23
23
  }: RestrictMobilePlaybackProps): { isRestricted: boolean } => {
24
24
  const dialogVisibleRef = useRef<boolean>(false);
25
25
  const theme = useTheme();
26
+ const plugins = usePlugins();
27
+
28
+ const restrictMobilePlugin = useMemo(
29
+ () =>
30
+ plugins.find((p) => p.identifier === "quick-brick-hook-restrict-mobile"),
31
+ [plugins]
32
+ );
33
+
34
+ const localizations = useMemo(
35
+ () => restrictMobilePlugin?.configuration?.localizations,
36
+ [restrictMobilePlugin]
37
+ );
38
+
39
+ const localize = useCallback(
40
+ (key: string) => {
41
+ const l = getLocalizations({ localizations });
42
+
43
+ return (l && l[key]) || "";
44
+ },
45
+ [localizations]
46
+ );
26
47
 
27
48
  useEffect(() => {
28
49
  return () => {
@@ -39,8 +60,13 @@ export const useRestrictMobilePlayback = ({
39
60
  return false;
40
61
  }
41
62
 
63
+ // Only restrict if the plugin exists
64
+ if (!restrictMobilePlugin) {
65
+ return false;
66
+ }
67
+
42
68
  return player && entry?.extensions?.connection_restricted;
43
- }, [player, entry]);
69
+ }, [player, entry, restrictMobilePlugin]);
44
70
 
45
71
  const [isRestricted, setIsRestricted] = useState<boolean>(
46
72
  isConnectionRestricted
@@ -63,10 +89,10 @@ export const useRestrictMobilePlayback = ({
63
89
 
64
90
  showAlertDialog({
65
91
  title:
66
- pluginConfiguration?.mobile_connection_restricted_alert_title ||
92
+ localize("restrict_mobile_playback_error_title") ||
67
93
  "Restricted Connection Type",
68
94
  message:
69
- pluginConfiguration?.mobile_connection_restricted_alert_message ||
95
+ localize("restrict_mobile_playback_error_message") ||
70
96
  "This content can only be viewed over a Wi-Fi or LAN network.",
71
97
  okButtonText: theme.ok_button || "OK",
72
98
  completion: () => {
@@ -93,7 +119,8 @@ export const useRestrictMobilePlayback = ({
93
119
  }, [
94
120
  close,
95
121
  entry?.extensions?.connection_restricted,
96
- pluginConfiguration,
122
+ localizations,
123
+ localize,
97
124
  player,
98
125
  theme.ok_button,
99
126
  isConnectionRestricted,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "15.0.0-alpha.6222113329",
3
+ "version": "15.0.0-alpha.6685355529",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "15.0.0-alpha.6222113329",
32
- "@applicaster/zapp-react-native-bridge": "15.0.0-alpha.6222113329",
33
- "@applicaster/zapp-react-native-redux": "15.0.0-alpha.6222113329",
34
- "@applicaster/zapp-react-native-utils": "15.0.0-alpha.6222113329",
31
+ "@applicaster/applicaster-types": "15.0.0-alpha.6685355529",
32
+ "@applicaster/zapp-react-native-bridge": "15.0.0-alpha.6685355529",
33
+ "@applicaster/zapp-react-native-redux": "15.0.0-alpha.6685355529",
34
+ "@applicaster/zapp-react-native-utils": "15.0.0-alpha.6685355529",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "url": "^0.11.0",