@applicaster/quick-brick-player 16.0.0-alpha.6861239588 → 16.0.0-alpha.6918106967

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.
Files changed (31) hide show
  1. package/package.json +6 -6
  2. package/src/Player/AudioLayer/AudioDescription.tsx +46 -11
  3. package/src/Player/AudioLayer/AudioPlayerWrapper.tsx +38 -48
  4. package/src/Player/AudioLayer/Layout/Controls/__tests__/utils.test.ts +87 -0
  5. package/src/Player/AudioLayer/Layout/Controls/index.tsx +34 -14
  6. package/src/Player/AudioLayer/Layout/Controls/utils.ts +40 -0
  7. package/src/Player/AudioLayer/Layout/DockedControls/index.tsx +1 -13
  8. package/src/Player/AudioLayer/Layout/MobileLayout.tsx +0 -4
  9. package/src/Player/AudioLayer/Layout/TabletLandscapeLayout.tsx +0 -4
  10. package/src/Player/AudioLayer/Layout/TabletPortraitLayout.tsx +0 -4
  11. package/src/Player/AudioLayer/Layout/TransportInfo/__tests__/index.test.tsx +257 -0
  12. package/src/Player/AudioLayer/Layout/TransportInfo/index.tsx +69 -8
  13. package/src/Player/AudioLayer/SleepTimerManager.ts +5 -1
  14. package/src/Player/AudioLayer/SpeedManager.ts +4 -0
  15. package/src/Player/AudioLayer/__tests__/AudioDescription.test.tsx +147 -0
  16. package/src/Player/AudioLayer/__tests__/AudioPlayerWrapper.test.tsx +130 -0
  17. package/src/Player/AudioLayer/__tests__/SleepTimerManager.test.ts +78 -0
  18. package/src/Player/AudioLayer/__tests__/SpeedManager.test.ts +57 -0
  19. package/src/Player/AudioLayer/__tests__/playerActions.test.ts +369 -0
  20. package/src/Player/AudioLayer/__tests__/usePlaylistNavigation.test.ts +387 -0
  21. package/src/Player/AudioLayer/playerActions.ts +294 -0
  22. package/src/Player/AudioLayer/usePlaylistNavigation.ts +134 -0
  23. package/src/Player/AudioLayer/useSleepTimerModal.ts +20 -57
  24. package/src/Player/PlayerModal/VideoPlayerModal.tsx +18 -1
  25. package/src/Player/PlayerModal/__tests__/VideoPlayerModal.test.tsx +160 -0
  26. package/src/Player/__tests__/getNativeProps.test.ts +115 -0
  27. package/src/Player/__tests__/onTracksChanged.test.ts +192 -0
  28. package/src/Player/__tests__/toNativeMetadata.test.ts +77 -0
  29. package/src/Player/index.tsx +146 -15
  30. package/src/Player/AudioLayer/components/SleepTimerModalHeader/SleepTimerModalHeader.tsx +0 -66
  31. package/src/Player/AudioLayer/components/SleepTimerModalHeader/index.ts +0 -1
@@ -0,0 +1,192 @@
1
+ import VideoPlayer from "../index";
2
+ import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
3
+
4
+ /**
5
+ * Tests for the track-selection reconciliation logic in `onTracksChanged`.
6
+ *
7
+ * The handler uses `resolveReportedTrackId` to prevent an infinite feedback
8
+ * loop: a transient native "nothing selected" (reported id === undefined)
9
+ * must NOT clear controlled state when the previous track is still available,
10
+ * while genuine track changes must still propagate.
11
+ *
12
+ * Instances are constructed directly (no render) to keep these tests fast and
13
+ * focused on the instance method, mirroring the pattern used in
14
+ * `getNativeProps.test.ts`.
15
+ */
16
+
17
+ jest.mock("@applicaster/zapp-react-native-utils/appUtils", () => ({
18
+ ...jest.requireActual("@applicaster/zapp-react-native-utils/appUtils"),
19
+ playerManager: {
20
+ getPlayerWithId: jest.fn(),
21
+ },
22
+ }));
23
+
24
+ jest.mock(
25
+ "@applicaster/zapp-react-native-utils/playerUtils/configurationUtils",
26
+ () => ({
27
+ parseLanguageTracks: jest.fn(),
28
+ })
29
+ );
30
+
31
+ import { parseLanguageTracks } from "@applicaster/zapp-react-native-utils/playerUtils/configurationUtils";
32
+
33
+ const baseProps = {
34
+ entry: { id: "1", title: "Entry Title", summary: "Entry Summary" },
35
+ pluginConfiguration: {},
36
+ docked: false,
37
+ fullscreen: false,
38
+ inline: false,
39
+ isModal: false,
40
+ isTabletPortrait: false,
41
+ muted: false,
42
+ playerId: "player-1",
43
+ PlayerComponent: "QuickBrickDefaultPlayerView",
44
+ } as unknown as ConstructorParameters<typeof VideoPlayer>[0];
45
+
46
+ const audioTrack = { id: "en-audio", type: "audio" };
47
+ const textTrack = { id: "en-text", type: "text" };
48
+
49
+ /** Helper: call onTracksChanged with a mocked parseLanguageTracks result. */
50
+ function callOnTracksChanged(
51
+ instance: VideoPlayer,
52
+ parsed: {
53
+ audioTracks?: { id: string; type: string }[];
54
+ textTracks?: { id: string; type: string }[];
55
+ audioTrackId?: string | undefined;
56
+ textTrackId?: string | undefined;
57
+ }
58
+ ) {
59
+ (parseLanguageTracks as jest.Mock).mockReturnValue({
60
+ audioTracks: [],
61
+ textTracks: [],
62
+ audioTrackId: undefined,
63
+ textTrackId: undefined,
64
+ ...parsed,
65
+ });
66
+
67
+ instance.onTracksChanged({ nativeEvent: {} });
68
+ }
69
+
70
+ describe("onTracksChanged — resolveReportedTrackId reconciliation", () => {
71
+ beforeEach(() => {
72
+ (playerManager.getPlayerWithId as jest.Mock).mockReturnValue(null);
73
+ });
74
+
75
+ it("sets audioTrackId and textTrackId when native reports real selections", () => {
76
+ const instance = new VideoPlayer(baseProps);
77
+ const setState = jest.spyOn(instance, "setState");
78
+
79
+ callOnTracksChanged(instance, {
80
+ audioTracks: [audioTrack],
81
+ textTracks: [textTrack],
82
+ audioTrackId: audioTrack.id,
83
+ textTrackId: textTrack.id,
84
+ });
85
+
86
+ expect(setState).toHaveBeenCalledWith(
87
+ expect.objectContaining({
88
+ audioTrackId: audioTrack.id,
89
+ textTrackId: textTrack.id,
90
+ }),
91
+ expect.any(Function)
92
+ );
93
+ });
94
+
95
+ it("does NOT clear audioTrackId when native transiently reports undefined and the track is still in the list", () => {
96
+ const instance = new VideoPlayer(baseProps);
97
+ // Establish prior selection state without a React reconciler.
98
+ instance.state = { ...instance.state, audioTrackId: audioTrack.id };
99
+
100
+ const setState = jest.spyOn(instance, "setState");
101
+
102
+ callOnTracksChanged(instance, {
103
+ audioTracks: [audioTrack],
104
+ textTracks: [],
105
+ audioTrackId: undefined, // transient native blip — nothing selected
106
+ textTrackId: undefined,
107
+ });
108
+
109
+ // State must NOT change because the resolved id equals the current id.
110
+ expect(setState).not.toHaveBeenCalled();
111
+ });
112
+
113
+ it("does NOT clear textTrackId when native transiently reports undefined and the track is still in the list", () => {
114
+ const instance = new VideoPlayer(baseProps);
115
+ instance.state = { ...instance.state, textTrackId: textTrack.id };
116
+
117
+ const setState = jest.spyOn(instance, "setState");
118
+
119
+ callOnTracksChanged(instance, {
120
+ audioTracks: [],
121
+ textTracks: [textTrack],
122
+ audioTrackId: undefined,
123
+ textTrackId: undefined,
124
+ });
125
+
126
+ expect(setState).not.toHaveBeenCalled();
127
+ });
128
+
129
+ it("clears the id when the previously-selected track is no longer present in the list", () => {
130
+ const instance = new VideoPlayer(baseProps);
131
+ instance.state = { ...instance.state, audioTrackId: audioTrack.id };
132
+
133
+ const setState = jest.spyOn(instance, "setState");
134
+
135
+ // Track is gone from the available list.
136
+ callOnTracksChanged(instance, {
137
+ audioTracks: [], // track not available anymore
138
+ textTracks: [],
139
+ audioTrackId: undefined,
140
+ textTrackId: undefined,
141
+ });
142
+
143
+ expect(setState).toHaveBeenCalledWith(
144
+ expect.objectContaining({ audioTrackId: null }),
145
+ expect.any(Function)
146
+ );
147
+ });
148
+
149
+ it("propagates a genuine track change to a different id", () => {
150
+ const newTrack = { id: "fr-audio", type: "audio" };
151
+ const instance = new VideoPlayer(baseProps);
152
+ instance.state = { ...instance.state, audioTrackId: audioTrack.id };
153
+
154
+ const setState = jest.spyOn(instance, "setState");
155
+
156
+ callOnTracksChanged(instance, {
157
+ audioTracks: [audioTrack, newTrack],
158
+ textTracks: [],
159
+ audioTrackId: newTrack.id,
160
+ textTrackId: undefined,
161
+ });
162
+
163
+ expect(setState).toHaveBeenCalledWith(
164
+ expect.objectContaining({ audioTrackId: newTrack.id }),
165
+ expect.any(Function)
166
+ );
167
+ });
168
+
169
+ it("calls the listener with resolved ids even when state does not change", () => {
170
+ const instance = new VideoPlayer(baseProps);
171
+ instance.state = { ...instance.state, audioTrackId: audioTrack.id };
172
+
173
+ const onTracksChangedListener = jest.fn();
174
+
175
+ (instance as any).props = {
176
+ ...instance.props,
177
+ listener: { onTracksChanged: onTracksChangedListener },
178
+ };
179
+
180
+ callOnTracksChanged(instance, {
181
+ audioTracks: [audioTrack],
182
+ textTracks: [],
183
+ audioTrackId: undefined, // transient blip
184
+ textTrackId: undefined,
185
+ });
186
+
187
+ // notifyListener is called with the resolved (non-null) audioTrackId
188
+ expect(onTracksChangedListener).toHaveBeenCalledWith(
189
+ expect.objectContaining({ audioTrackId: audioTrack.id })
190
+ );
191
+ });
192
+ });
@@ -0,0 +1,77 @@
1
+ import { toNativeMetadata } from "../index";
2
+
3
+ // `toNativeMetadata` used to be `resolveNativeTitleSubtitle`, which resolved
4
+ // Title/Subtitle from `entry` + `pluginConfiguration` itself (the dot-path /
5
+ // custom-key / fallback logic). That resolution now happens once in
6
+ // `Player.getContent()` (via `resolvePlayerTitleSubtitle`, already covered by
7
+ // `playerUtils/__tests__/resolvePlayerTitleSubtitle.test.ts` and
8
+ // `playerUtils/__tests__/contentDataKeys.test.ts` - custom-key resolution,
9
+ // fallback-when-unresolvable, and entry-non-mutation are all still asserted
10
+ // there). `toNativeMetadata` only adapts the already-resolved
11
+ // `player.getContent()` value into the `metadata` object the native bridge
12
+ // receives, so this file only covers that adaptation: the shape coercion, and
13
+ // the numeric coercion the native bridge specifically needs (it cannot render
14
+ // a number the way `<Text>` can).
15
+ describe("toNativeMetadata", () => {
16
+ it("returns undefined for both fields when title/summary are null (what the player publishes when there is nothing to show)", () => {
17
+ expect(toNativeMetadata({ title: null, summary: null })).toEqual({
18
+ title: undefined,
19
+ subtitle: undefined,
20
+ });
21
+ });
22
+
23
+ it("returns undefined for both fields when content itself is undefined", () => {
24
+ expect(toNativeMetadata(undefined)).toEqual({
25
+ title: undefined,
26
+ subtitle: undefined,
27
+ });
28
+ });
29
+
30
+ it("passes through string title/summary as-is", () => {
31
+ expect(
32
+ toNativeMetadata({
33
+ title: "Resolved Title",
34
+ summary: "Resolved Summary",
35
+ })
36
+ ).toEqual({
37
+ title: "Resolved Title",
38
+ subtitle: "Resolved Summary",
39
+ });
40
+ });
41
+
42
+ it("coerces a numeric title/summary to a string for the native bridge", () => {
43
+ expect(toNativeMetadata({ title: 0, summary: 42 })).toEqual({
44
+ title: "0",
45
+ subtitle: "42",
46
+ });
47
+ });
48
+
49
+ it("handles title and summary independently (one present, one absent)", () => {
50
+ expect(toNativeMetadata({ title: "Only Title", summary: null })).toEqual({
51
+ title: "Only Title",
52
+ subtitle: undefined,
53
+ });
54
+ });
55
+
56
+ it("passes the cover image url through", () => {
57
+ expect(
58
+ toNativeMetadata({
59
+ title: "A Title",
60
+ summary: "A Summary",
61
+ imageUrl: "https://img.test/base.jpg",
62
+ })
63
+ ).toEqual({
64
+ title: "A Title",
65
+ subtitle: "A Summary",
66
+ imageUrl: "https://img.test/base.jpg",
67
+ });
68
+ });
69
+
70
+ it("sends undefined rather than an empty string when there is no image", () => {
71
+ // Native treats an empty URI as a load attempt; `undefined` means "none".
72
+ expect(
73
+ toNativeMetadata({ title: "A Title", summary: null, imageUrl: null })
74
+ .imageUrl
75
+ ).toBeUndefined();
76
+ });
77
+ });
@@ -52,7 +52,7 @@ import { TVPlayerView } from "./PlayerView/TVPlayerView";
52
52
  import PlayerModal, { VideoPlayerModal } from "./PlayerModal";
53
53
  import { DockedControls } from "./AudioLayer/Layout/DockedControls";
54
54
  import { FlexImage } from "./AudioLayer/Layout/PlayerImage/FlexImage";
55
- import { PlayerError } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/conts";
55
+ import { PlayerError } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/const";
56
56
 
57
57
  const isTvOS = isTvOSPlatform();
58
58
 
@@ -69,6 +69,60 @@ const styles = StyleSheet.create({
69
69
  flexImage: { height: "100%", aspectRatio: 1, flex: -1 },
70
70
  });
71
71
 
72
+ /**
73
+ * Coerces the resolver's `Option<string | number>` result into what the
74
+ * native bridge expects: a string, or `undefined` when there is nothing to
75
+ * send.
76
+ */
77
+ const toNativeTextProp = (
78
+ value: Option<string | number>
79
+ ): string | undefined =>
80
+ value === null || value === undefined ? undefined : String(value);
81
+
82
+ export type NativePlayerMetadata = {
83
+ title: string | undefined;
84
+ subtitle: string | undefined;
85
+ imageUrl: string | undefined;
86
+ };
87
+
88
+ /**
89
+ * Adapts the player's resolved Title/Subtitle into the `metadata` object the
90
+ * *native* view receives.
91
+ *
92
+ * The resolution itself (dot-path / key-set logic, entry fallback) does not
93
+ * happen here - the player manager resolves it and publishes it on its content
94
+ * channel (`player.getContent()`). This function only coerces that value's
95
+ * `Option<string | number>` shape into what the native bridge needs: a string,
96
+ * or `undefined` when there is nothing to send.
97
+ *
98
+ * Travels as one `metadata` object rather than two flat props so native has a
99
+ * single place to look for player-facing text, and so adding a field later
100
+ * does not widen the bridge's prop surface again.
101
+ *
102
+ * This intentionally does not touch `entry` - analytics and the downloads
103
+ * feature read `entry.title` / `entry.summary` directly and must keep
104
+ * seeing the original feed values (the downloads feature requires the
105
+ * original entry title). The resolved (possibly customer-configured) text
106
+ * travels in `metadata` instead.
107
+ *
108
+ * Exported as a plain function (rather than inlined as a class method) so
109
+ * it can be unit tested directly without rendering the ~37KB `VideoPlayer`
110
+ * class component.
111
+ */
112
+ export const toNativeMetadata = (
113
+ content: Option<{
114
+ title: Option<string | number>;
115
+ summary: Option<string | number>;
116
+ imageUrl?: Option<string>;
117
+ }>
118
+ ): NativePlayerMetadata => ({
119
+ title: toNativeTextProp(content?.title),
120
+ subtitle: toNativeTextProp(content?.summary),
121
+ // Already a string when present; coerced through the same helper so an
122
+ // empty or nullish value reaches native as `undefined` rather than "".
123
+ imageUrl: toNativeTextProp(content?.imageUrl),
124
+ });
125
+
72
126
  type VideoPlayerProps = QuickBrickPlayer.PlayerProps & {
73
127
  isCasting?: boolean;
74
128
  playNextData?: PlayNextData;
@@ -94,6 +148,38 @@ type VideoPlayerProps = QuickBrickPlayer.PlayerProps & {
94
148
  children?: React.ReactNode;
95
149
  };
96
150
 
151
+ /**
152
+ * `textTrackId`/`audioTrackId` are both the value the native player *reports* as
153
+ * currently selected AND the *controlled prop* that drives native selection.
154
+ * Because of that dual role, reflecting a reported value straight back down turns
155
+ * a status update into a command.
156
+ *
157
+ * The native player can momentarily report "nothing selected" (index -1, which
158
+ * `parseLanguageTracks` maps to `undefined`) during normal fMP4/ABR segment
159
+ * transitions. Pushing that back down as a "disable"/"clear" command flips native
160
+ * state, which emits a fresh onTracksChanged, which we would echo again — an
161
+ * infinite feedback loop.
162
+ *
163
+ * Keep the current selection when the reported value is a transient drop and the
164
+ * chosen track is still available. A genuine user "Off"/change already updates the
165
+ * controlled state first, so this only ignores unsolicited native status blips.
166
+ */
167
+ const resolveReportedTrackId = (
168
+ reportedId: string | null | undefined,
169
+ currentId: string | null,
170
+ tracks: { id: string }[] = []
171
+ ): string | null => {
172
+ if (reportedId) {
173
+ return reportedId;
174
+ }
175
+
176
+ if (currentId && tracks.some((track) => track?.id === currentId)) {
177
+ return currentId;
178
+ }
179
+
180
+ return null;
181
+ };
182
+
97
183
  export default class VideoPlayer extends React.Component<
98
184
  VideoPlayerProps,
99
185
  QuickBrickPlayer.NativePlayerState & {
@@ -643,20 +729,50 @@ export default class VideoPlayer extends React.Component<
643
729
  const { textTracks, audioTracks, audioTrackId, textTrackId } =
644
730
  parseLanguageTracks(nativeEvent);
645
731
 
646
- this.setState(
647
- {
648
- audioTrackId,
649
- textTrackId,
650
- },
651
- () => {
652
- this.props?.listener?.onTracksChanged?.({
653
- textTracks,
654
- audioTracks,
655
- audioTrackId,
656
- textTrackId,
657
- });
658
- }
732
+ // Resolve the reported selection against the current controlled state so a
733
+ // transient native "nothing selected" doesn't get echoed back as a command
734
+ // and re-trigger native selection (infinite loop, see resolveReportedTrackId).
735
+ const nextAudioTrackId = resolveReportedTrackId(
736
+ audioTrackId,
737
+ this.state.audioTrackId,
738
+ audioTracks
659
739
  );
740
+
741
+ const nextTextTrackId = resolveReportedTrackId(
742
+ textTrackId,
743
+ this.state.textTrackId,
744
+ textTracks
745
+ );
746
+
747
+ const notifyListener = () =>
748
+ this.props?.listener?.onTracksChanged?.({
749
+ textTracks,
750
+ audioTracks,
751
+ audioTrackId: nextAudioTrackId,
752
+ textTrackId: nextTextTrackId,
753
+ });
754
+
755
+ // Only update state (and thus re-send the controlled props) on a real change.
756
+ // Re-rendering with identical prop values would otherwise keep the native
757
+ // event/prop echo alive.
758
+ const stateChanges: {
759
+ audioTrackId?: string | null;
760
+ textTrackId?: string | null;
761
+ } = {};
762
+
763
+ if (nextAudioTrackId !== this.state.audioTrackId) {
764
+ stateChanges.audioTrackId = nextAudioTrackId;
765
+ }
766
+
767
+ if (nextTextTrackId !== this.state.textTrackId) {
768
+ stateChanges.textTrackId = nextTextTrackId;
769
+ }
770
+
771
+ if (Object.keys(stateChanges).length > 0) {
772
+ this.setState(stateChanges as any, notifyListener);
773
+ } else {
774
+ notifyListener();
775
+ }
660
776
  };
661
777
 
662
778
  onVideoProgress = ({ nativeEvent }) => {
@@ -1072,6 +1188,15 @@ export default class VideoPlayer extends React.Component<
1072
1188
  const liveCatchUpEnabled =
1073
1189
  this.props.pluginConfiguration?.liveCatchUpEnabled;
1074
1190
 
1191
+ // Look the player up by id rather than using the active player: these
1192
+ // props are handed to this component's own native player view, so they
1193
+ // must describe that player's content even while a cast session is
1194
+ // running (during which `usePlayer` swaps React consumers over to the
1195
+ // casting receiver).
1196
+ const metadata = toNativeMetadata(
1197
+ playerManager.getPlayerWithId(this.props.playerId)?.getContent()
1198
+ );
1199
+
1075
1200
  const nativeProps = {
1076
1201
  rate: undefined,
1077
1202
  entry,
@@ -1090,6 +1215,7 @@ export default class VideoPlayer extends React.Component<
1090
1215
  liveCatchUpEnabled,
1091
1216
  playerId: this.props.playerId,
1092
1217
  pictureInPictureEnabled,
1218
+ metadata,
1093
1219
  seekStep:
1094
1220
  (this.props.pluginConfiguration?.seek_duration || SEEK_TIME) * 1000,
1095
1221
  accessibilityProps: getAllAccessibilityProps(
@@ -1146,10 +1272,15 @@ export default class VideoPlayer extends React.Component<
1146
1272
  return null;
1147
1273
  }
1148
1274
 
1149
- const TransportControls = isTV()
1275
+ const isTvPlatform = isTV();
1276
+
1277
+ const TransportControls = isTvPlatform
1150
1278
  ? TransportControlsTV
1151
1279
  : TransportControlsMobile;
1152
1280
 
1281
+ // The mobile and TV transport controls read Title/Subtitle from the
1282
+ // player manager's content channel (via `usePlayerContent`) instead of
1283
+ // receiving them as props.
1153
1284
  const needToShowDefaultControls = !(
1154
1285
  (controls && !castAction?.state?.connected) ||
1155
1286
  this.getPlayNextData()
@@ -1,66 +0,0 @@
1
- import React from "react";
2
- import { ModalHeader } from "@applicaster/zapp-react-native-ui-components/Components/ModalComponent/Header";
3
- import { isNil } from "@applicaster/zapp-react-native-utils/utils";
4
-
5
- const formatTime = (milliseconds: number) => {
6
- const totalSeconds = Math.floor(milliseconds / 1000);
7
- const hours = Math.floor(totalSeconds / 3600);
8
- const minutes = Math.floor((totalSeconds % 3600) / 60);
9
- const seconds = totalSeconds % 60;
10
-
11
- if (milliseconds < 3600000) {
12
- return `${minutes.toString().padStart(2, "0")}:${seconds
13
- .toString()
14
- .padStart(2, "0")}`;
15
- }
16
-
17
- return `${hours.toString().padStart(2, "0")}:${minutes
18
- .toString()
19
- .padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
20
- };
21
-
22
- export const SleepTimerModalHeader = ({
23
- summary,
24
- ...props
25
- }: {
26
- summary?: string;
27
- }) => {
28
- const sleepTimerDate = +summary;
29
-
30
- const [timeLeft, setTimeLeft] = React.useState(
31
- sleepTimerDate !== 0 ? sleepTimerDate - Date.now() : 0
32
- );
33
-
34
- const showCounter = React.useMemo(() => sleepTimerDate > 0, [sleepTimerDate]);
35
-
36
- React.useLayoutEffect(() => {
37
- if (showCounter && sleepTimerDate !== 0) {
38
- setTimeLeft(sleepTimerDate - Date.now());
39
-
40
- const intervalId = setInterval(() => {
41
- setTimeLeft(() => {
42
- const newTimeLeft = sleepTimerDate - Date.now();
43
-
44
- if (newTimeLeft <= 0) {
45
- clearInterval(intervalId);
46
-
47
- return 0;
48
- } else {
49
- return newTimeLeft;
50
- }
51
- });
52
- }, 1000);
53
-
54
- return () => clearInterval(intervalId);
55
- } else {
56
- setTimeLeft(0);
57
- }
58
- }, [sleepTimerDate, showCounter]);
59
-
60
- return (
61
- <ModalHeader
62
- summary={!isNil(summary) ? formatTime(timeLeft) : summary}
63
- {...(props as any)}
64
- />
65
- );
66
- };
@@ -1 +0,0 @@
1
- export * from "./SleepTimerModalHeader";