@applicaster/zapp-react-native-utils 15.0.0-alpha.9102699023 → 15.0.0-alpha.9102777840

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.
@@ -0,0 +1,216 @@
1
+ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
2
+ import { interval, Subject, Subscription } from "rxjs";
3
+ import { map, filter, throttleTime } from "rxjs/operators";
4
+
5
+ import { getDataRefreshConfig } from "./utils";
6
+
7
+ export { getDataRefreshConfig, type RefreshConfig } from "./utils";
8
+
9
+ const THROTTLE_TIMEOUT = 500; // ms
10
+
11
+ type ComponentToRefresh = {
12
+ component: ZappUIComponent;
13
+ screenId: string;
14
+ };
15
+
16
+ /**
17
+ * Public contract for refresh coordination.
18
+ *
19
+ * register() → starts refresh timer for a component with screen context
20
+ * subscribeTo() → listen to refresh events for a specific component and screen
21
+ * subscribeToAny() → listen to all refresh events with throttling
22
+ */
23
+ interface IRefreshCoordinator {
24
+ register(component: ZappUIComponent, screenId: string): () => void;
25
+ subscribeTo(
26
+ component: ZappUIComponent,
27
+ screenId: string,
28
+ listener: () => void
29
+ ): Subscription;
30
+ subscribeToAny(
31
+ listener: (componentToRefresh: ComponentToRefresh) => void
32
+ ): Subscription;
33
+ }
34
+
35
+ /**
36
+ * Singleton implementation of RefreshCoordinator.
37
+ *
38
+ * Design goals:
39
+ * - One shared coordinator across the app
40
+ * - Multiple components can register refresh timers with screen context
41
+ * - Multiple listeners can subscribe to refresh events
42
+ * - Safe cleanup of timers and subscriptions
43
+ */
44
+ class RefreshCoordinator implements IRefreshCoordinator {
45
+ private static instance: RefreshCoordinator;
46
+
47
+ /**
48
+ * Active timers per component/screen pair ((componentId, screenId) → RxJS Subscription).
49
+ * Each entry is keyed by a composite of componentId and screenId (via getKey),
50
+ * and gets its own interval stream for periodic refresh.
51
+ */
52
+ private timers: Map<string, Subscription> = new Map();
53
+
54
+ /**
55
+ * Central event stream emitting components that need refresh.
56
+ * All component interval streams push into this Subject.
57
+ * Multiple listeners can subscribe to receive refresh events for specific components.
58
+ * This is the core stream that coordinates all refresh operations.
59
+ */
60
+ private refresh$ = new Subject<ComponentToRefresh>();
61
+
62
+ // Store the current single subscriber for subscribeToAny
63
+ private anyListenerSubscription?: Subscription;
64
+
65
+ private constructor() {}
66
+
67
+ public static getInstance(): RefreshCoordinator {
68
+ if (!RefreshCoordinator.instance) {
69
+ RefreshCoordinator.instance = new RefreshCoordinator();
70
+ }
71
+
72
+ return RefreshCoordinator.instance;
73
+ }
74
+
75
+ /**
76
+ * Registers a component for periodic refresh.
77
+ *
78
+ * Behavior:
79
+ * - If the component was previously registered, its timer is replaced.
80
+ * - If refreshing is disabled, nothing is scheduled.
81
+ * - Returns an unregister function for manual cleanup.
82
+ * - Each component gets its own interval stream for periodic refresh.
83
+ */
84
+ public register(component: ZappUIComponent, screenId: string): () => void {
85
+ const componentId: ZappUIComponent["id"] = component.id;
86
+
87
+ // Ensure no duplicate timer exists for this component
88
+ this.unregister(componentId, screenId);
89
+
90
+ const refreshConfig = getDataRefreshConfig(component);
91
+
92
+ // If refreshing disabled → do nothing
93
+ if (!refreshConfig.isRefreshingEnabled) {
94
+ return noop;
95
+ }
96
+
97
+ /**
98
+ * Create interval stream:
99
+ * - Emits every refreshIntervalMs
100
+ * - Maps emission to the ComponentToRefresh object
101
+ * - Pushes component into central refresh$ stream
102
+ */
103
+ const subscription: Subscription = interval(refreshConfig.refreshIntervalMs)
104
+ .pipe(
105
+ map(() => ({
106
+ component,
107
+ screenId,
108
+ }))
109
+ )
110
+ .subscribe(this.refresh$);
111
+
112
+ this.timers.set(this.getKey(componentId, screenId), subscription);
113
+
114
+ return (): void => this.unregister(componentId, screenId);
115
+ }
116
+
117
+ /**
118
+ * Stops and removes timer for a specific component.
119
+ * Cleans up the RxJS subscription for that component's interval stream.
120
+ */
121
+ private unregister(
122
+ componentId: ZappUIComponent["id"],
123
+ screenId: string
124
+ ): void {
125
+ const key = this.getKey(componentId, screenId);
126
+ const subscription: Subscription | undefined = this.timers.get(key);
127
+
128
+ if (subscription) {
129
+ subscription.unsubscribe();
130
+ this.timers.delete(key);
131
+ }
132
+ }
133
+
134
+ private getKey(componentId: ZappUIComponent["id"], screenId: string): string {
135
+ return `componentId:${componentId}___screenId:${screenId}`;
136
+ }
137
+
138
+ /**
139
+ * Subscribes to refresh events for a specific component.
140
+ *
141
+ * Each subscription is independent - multiple listeners can subscribe
142
+ * to the same component's refresh events.
143
+ */
144
+ public subscribeTo(
145
+ component: ZappUIComponent,
146
+ screenId: string,
147
+ listener: () => void
148
+ ): Subscription {
149
+ return this.refresh$
150
+ .pipe(
151
+ filter(
152
+ (componentToRefresh: ComponentToRefresh) =>
153
+ componentToRefresh.component.id === component.id &&
154
+ componentToRefresh.screenId === screenId
155
+ )
156
+ )
157
+ .subscribe(listener);
158
+ }
159
+
160
+ /**
161
+ * Subscribes a single global listener to all refresh events.
162
+ *
163
+ * Behavior:
164
+ * - Only one active listener exists at a time.
165
+ * - If a previous listener was already subscribed, it is automatically unsubscribed.
166
+ * - Throttles refresh events to emit at most once per THROTTLE_TIMEOUT interval.
167
+ * - Useful for scenarios where you want a single handler to react
168
+ * to any component refresh without having multiple active callbacks.
169
+ *
170
+ * @param listener - Callback to invoke whenever any component triggers a refresh
171
+ * @returns The RxJS Subscription object for this listener
172
+ */
173
+ public subscribeToAny(
174
+ listener: (componentToRefresh: ComponentToRefresh) => void
175
+ ): Subscription {
176
+ // Unsubscribe previous listener if present to enforce "single active listener" policy
177
+ if (this.anyListenerSubscription) {
178
+ this.anyListenerSubscription.unsubscribe();
179
+ }
180
+
181
+ // Create a new throttled subscription
182
+ this.anyListenerSubscription = this.refresh$
183
+ .pipe(throttleTime(THROTTLE_TIMEOUT))
184
+ .subscribe(listener);
185
+
186
+ return this.anyListenerSubscription;
187
+ }
188
+
189
+ /**
190
+ * Fully resets coordinator state.
191
+ *
192
+ * Clears:
193
+ * - All component timers
194
+ * - Any active "subscribeToAny" listener
195
+ * - Recreates internal Subject to allow fresh subscriptions
196
+ */
197
+ public clear(): void {
198
+ // Stop and remove all active timers
199
+ this.timers.forEach((sub: Subscription) => sub.unsubscribe());
200
+ this.timers.clear();
201
+
202
+ // Stop any active "subscribeToAny" subscription
203
+ if (this.anyListenerSubscription) {
204
+ this.anyListenerSubscription.unsubscribe();
205
+ this.anyListenerSubscription = undefined;
206
+ }
207
+
208
+ // Complete old Subject to release subscribers
209
+ this.refresh$.complete();
210
+
211
+ // Recreate Subject so coordinator can be reused
212
+ this.refresh$ = new Subject<ComponentToRefresh>();
213
+ }
214
+ }
215
+
216
+ export const refreshCoordinator = RefreshCoordinator.getInstance();
@@ -0,0 +1,104 @@
1
+ import {
2
+ getDataRefreshConfig,
3
+ MINIMUM_REFRESHING_INTERVAL_IN_SECONDS,
4
+ DEFAULT_REFRESHING_INTERVAL_IN_SECONDS,
5
+ } from "..";
6
+
7
+ describe("getDataRefreshConfig", () => {
8
+ it("returns correct values when rules are defined", () => {
9
+ const component = {
10
+ rules: {
11
+ enable_data_refreshing: true,
12
+ refreshing_interval: 30,
13
+ },
14
+ } as any;
15
+
16
+ const result = getDataRefreshConfig(component);
17
+
18
+ expect(result).toEqual({
19
+ isRefreshingEnabled: true,
20
+ refreshIntervalMs: 30 * 1000,
21
+ });
22
+ });
23
+
24
+ it("returns false for isRefreshingEnabled if rules flag is false", () => {
25
+ const component = {
26
+ rules: {
27
+ enable_data_refreshing: false,
28
+ refreshing_interval: 45,
29
+ },
30
+ } as any;
31
+
32
+ const result = getDataRefreshConfig(component);
33
+
34
+ expect(result).toEqual({
35
+ isRefreshingEnabled: false,
36
+ refreshIntervalMs: 45 * 1000,
37
+ });
38
+ });
39
+
40
+ it("applies minimum interval if given interval is too low", () => {
41
+ const component = {
42
+ rules: {
43
+ enable_data_refreshing: true,
44
+ refreshing_interval: 2,
45
+ },
46
+ } as any;
47
+
48
+ const result = getDataRefreshConfig(component);
49
+
50
+ expect(result.refreshIntervalMs).toBe(
51
+ MINIMUM_REFRESHING_INTERVAL_IN_SECONDS * 1000
52
+ );
53
+ });
54
+
55
+ it("uses default interval when rules.refreshing_interval is undefined", () => {
56
+ const component = {
57
+ rules: {
58
+ enable_data_refreshing: true,
59
+ },
60
+ } as any;
61
+
62
+ const result = getDataRefreshConfig(component);
63
+
64
+ expect(result.refreshIntervalMs).toBe(
65
+ DEFAULT_REFRESHING_INTERVAL_IN_SECONDS * 1000
66
+ );
67
+ });
68
+
69
+ it("handles missing rules gracefully", () => {
70
+ const component = {} as any;
71
+
72
+ const result = getDataRefreshConfig(component);
73
+
74
+ expect(result).toEqual({
75
+ isRefreshingEnabled: false,
76
+ refreshIntervalMs: DEFAULT_REFRESHING_INTERVAL_IN_SECONDS * 1000,
77
+ });
78
+ });
79
+
80
+ it("handles null component gracefully", () => {
81
+ const result = getDataRefreshConfig(null as any);
82
+
83
+ expect(result).toEqual({
84
+ isRefreshingEnabled: false,
85
+ refreshIntervalMs: DEFAULT_REFRESHING_INTERVAL_IN_SECONDS * 1000,
86
+ });
87
+ });
88
+
89
+ it("handles string values for rules correctly", () => {
90
+ const component = {
91
+ rules: {
92
+ enable_data_refreshing: "true",
93
+ refreshing_interval: "25",
94
+ },
95
+ } as any;
96
+
97
+ const result = getDataRefreshConfig(component);
98
+
99
+ expect(result).toEqual({
100
+ isRefreshingEnabled: true,
101
+ refreshIntervalMs: 25 * 1000,
102
+ });
103
+ });
104
+ });
@@ -0,0 +1,29 @@
1
+ import { isTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
2
+ import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
3
+
4
+ export const MINIMUM_REFRESHING_INTERVAL_IN_SECONDS = 5; // 5 seconds
5
+
6
+ export const DEFAULT_REFRESHING_INTERVAL_IN_SECONDS = 60; // 1 minute
7
+
8
+ export type RefreshConfig = {
9
+ isRefreshingEnabled: boolean;
10
+ refreshIntervalMs: number;
11
+ };
12
+
13
+ export const getDataRefreshConfig = (
14
+ component: ZappUIComponent
15
+ ): RefreshConfig => {
16
+ const isRefreshingEnabled = isTrue(component?.rules?.enable_data_refreshing);
17
+
18
+ const refreshing_interval = toNumberWithDefault(
19
+ DEFAULT_REFRESHING_INTERVAL_IN_SECONDS,
20
+ component?.rules?.refreshing_interval
21
+ );
22
+
23
+ return {
24
+ isRefreshingEnabled,
25
+ refreshIntervalMs:
26
+ Math.max(refreshing_interval, MINIMUM_REFRESHING_INTERVAL_IN_SECONDS) *
27
+ 1000,
28
+ };
29
+ };
@@ -1,3 +1,5 @@
1
+ import { endsWith } from "@applicaster/zapp-react-native-utils/utils";
2
+
1
3
  export const getFocusableId = (id) => `PickerItem.${id}`;
2
4
 
3
5
  export const getPickerSelectorId = (id) => `PickerSelector.${id}`;
@@ -11,3 +13,6 @@ export const getScreenPickerSelectorContainerId = (id) =>
11
13
 
12
14
  export const getScreenPickerContentContainerId = (id) =>
13
15
  `${getScreenPickerId(id)}-screen-container`;
16
+
17
+ export const isTabsScreenContentContainerId = (id) =>
18
+ endsWith("-screen-container", id);
@@ -0,0 +1,3 @@
1
+ export const TV_SCREEN_HEIGHT = 1080;
2
+
3
+ export const TV_SCREEN_WIDTH = 1920;
@@ -0,0 +1,158 @@
1
+ import { clone } from "../clone";
2
+
3
+ describe("clone", () => {
4
+ const originalStructuredClone = global.structuredClone;
5
+
6
+ afterEach(() => {
7
+ // Restore the original structuredClone after each test
8
+ global.structuredClone = originalStructuredClone;
9
+ });
10
+
11
+ describe("when structuredClone is available", () => {
12
+ beforeEach(() => {
13
+ // Mock structuredClone if it's not available
14
+ if (typeof global.structuredClone === "undefined") {
15
+ global.structuredClone = jest.fn((value) =>
16
+ JSON.parse(JSON.stringify(value))
17
+ );
18
+ }
19
+ });
20
+
21
+ test("clones primitive values", () => {
22
+ expect(clone(42)).toBe(42);
23
+ expect(clone("test")).toBe("test");
24
+ expect(clone(true)).toBe(true);
25
+ expect(clone(null)).toBe(null);
26
+ });
27
+
28
+ test("clones simple objects", () => {
29
+ const original = { a: 1, b: 2 };
30
+ const cloned = clone(original);
31
+
32
+ expect(cloned).toEqual(original);
33
+ expect(cloned).not.toBe(original);
34
+ });
35
+
36
+ test("clones nested objects", () => {
37
+ const original = { a: { b: { c: 1 } } };
38
+ const cloned = clone(original);
39
+
40
+ expect(cloned).toEqual(original);
41
+ expect(cloned).not.toBe(original);
42
+ expect(cloned.a).not.toBe(original.a);
43
+ expect(cloned.a.b).not.toBe(original.a.b);
44
+ });
45
+
46
+ test("clones arrays", () => {
47
+ const original = [1, 2, 3];
48
+ const cloned = clone(original);
49
+
50
+ expect(cloned).toEqual(original);
51
+ expect(cloned).not.toBe(original);
52
+ });
53
+
54
+ test("clones arrays with nested objects", () => {
55
+ const original = [{ a: 1 }, { b: 2 }];
56
+ const cloned = clone(original);
57
+
58
+ expect(cloned).toEqual(original);
59
+ expect(cloned).not.toBe(original);
60
+ expect(cloned[0]).not.toBe(original[0]);
61
+ expect(cloned[1]).not.toBe(original[1]);
62
+ });
63
+
64
+ test("does not mutate the original value", () => {
65
+ const original = { a: 1, b: { c: 2 } };
66
+ const cloned = clone(original);
67
+
68
+ cloned.a = 99;
69
+ cloned.b.c = 99;
70
+
71
+ expect(original.a).toBe(1);
72
+ expect(original.b.c).toBe(2);
73
+ });
74
+ });
75
+
76
+ describe("when structuredClone is not available (fallback to cloneDeep)", () => {
77
+ beforeEach(() => {
78
+ // Delete structuredClone to force fallback to cloneDeep
79
+ delete (global as any).structuredClone;
80
+ });
81
+
82
+ test("clones primitive values using cloneDeep", () => {
83
+ expect(clone(42)).toBe(42);
84
+ expect(clone("test")).toBe("test");
85
+ expect(clone(true)).toBe(true);
86
+ expect(clone(null)).toBe(null);
87
+ });
88
+
89
+ test("clones simple objects using cloneDeep", () => {
90
+ const original = { a: 1, b: 2 };
91
+ const cloned = clone(original);
92
+
93
+ expect(cloned).toEqual(original);
94
+ expect(cloned).not.toBe(original);
95
+ });
96
+
97
+ test("clones nested objects using cloneDeep", () => {
98
+ const original = { a: { b: { c: 1 } } };
99
+ const cloned = clone(original);
100
+
101
+ expect(cloned).toEqual(original);
102
+ expect(cloned).not.toBe(original);
103
+ expect(cloned.a).not.toBe(original.a);
104
+ expect(cloned.a.b).not.toBe(original.a.b);
105
+ });
106
+
107
+ test("clones arrays using cloneDeep", () => {
108
+ const original = [1, 2, 3];
109
+ const cloned = clone(original);
110
+
111
+ expect(cloned).toEqual(original);
112
+ expect(cloned).not.toBe(original);
113
+ });
114
+
115
+ test("clones arrays with nested objects using cloneDeep", () => {
116
+ const original = [{ a: 1 }, { b: 2 }];
117
+ const cloned = clone(original);
118
+
119
+ expect(cloned).toEqual(original);
120
+ expect(cloned).not.toBe(original);
121
+ expect(cloned[0]).not.toBe(original[0]);
122
+ expect(cloned[1]).not.toBe(original[1]);
123
+ });
124
+
125
+ test("does not mutate the original value when using cloneDeep", () => {
126
+ const original = { a: 1, b: { c: 2 } };
127
+ const cloned = clone(original);
128
+
129
+ cloned.a = 99;
130
+ cloned.b.c = 99;
131
+
132
+ expect(original.a).toBe(1);
133
+ expect(original.b.c).toBe(2);
134
+ });
135
+
136
+ test("handles complex objects with multiple levels", () => {
137
+ const original = {
138
+ name: "test",
139
+ data: {
140
+ items: [
141
+ { id: 1, value: "a" },
142
+ { id: 2, value: "b" },
143
+ ],
144
+ meta: { count: 2 },
145
+ },
146
+ };
147
+
148
+ const cloned = clone(original);
149
+
150
+ expect(cloned).toEqual(original);
151
+ expect(cloned).not.toBe(original);
152
+ expect(cloned.data).not.toBe(original.data);
153
+ expect(cloned.data.items).not.toBe(original.data.items);
154
+ expect(cloned.data.items[0]).not.toBe(original.data.items[0]);
155
+ expect(cloned.data.meta).not.toBe(original.data.meta);
156
+ });
157
+ });
158
+ });
@@ -31,3 +31,10 @@ test("example 4", () => {
31
31
 
32
32
  expect(path(route, xs)).toBeUndefined();
33
33
  });
34
+
35
+ test("example 5", () => {
36
+ const route = ["a", "b", 0];
37
+ const xs = { a: { b: [1, 2, 3] } };
38
+
39
+ expect(path(route, xs)).toBe(1);
40
+ });
package/utils/clone.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { cloneDeep } from "lodash";
2
+
3
+ export const clone = (value) => {
4
+ return typeof structuredClone !== "undefined"
5
+ ? structuredClone(value) // no support for hermes, fallback to cloneDeep
6
+ : cloneDeep(value);
7
+ };
package/utils/index.ts CHANGED
@@ -20,8 +20,9 @@ export { mapAccum } from "./mapAccum";
20
20
 
21
21
  export { mergeRight } from "./mergeRight";
22
22
 
23
+ export { clone } from "./clone";
24
+
23
25
  export {
24
- cloneDeep as clone,
25
26
  flatten,
26
27
  drop,
27
28
  size,
@@ -1,75 +0,0 @@
1
- import { renderHook } from "@testing-library/react-native";
2
-
3
- jest.useFakeTimers();
4
-
5
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
6
- useIsScreenActive: () => true,
7
- }));
8
-
9
- const { useFeedRefresh, feedRefreshLogger } = require("..");
10
-
11
- describe("useFeedRefresh", () => {
12
- const reloadData = jest.fn();
13
-
14
- const component = {
15
- id: "foo",
16
- rules: { enable_data_refreshing: true, refreshing_interval: 61 },
17
- };
18
-
19
- it("Calls reloadData after passed time lapses", () => {
20
- renderHook(() => useFeedRefresh({ reloadData, component }));
21
-
22
- expect(reloadData).not.toBeCalled();
23
- jest.runOnlyPendingTimers();
24
- expect(reloadData).toBeCalled();
25
- });
26
-
27
- it("Logs warning message if refresh time set below minimum value", () => {
28
- const loggerSpy = jest.spyOn(feedRefreshLogger, "warning");
29
-
30
- renderHook(() =>
31
- useFeedRefresh({
32
- reloadData,
33
- component: {
34
- ...component,
35
- rules: { enable_data_refreshing: true, refreshing_interval: 2 },
36
- },
37
- })
38
- );
39
-
40
- expect(loggerSpy).toBeCalled();
41
- });
42
-
43
- it("Calls reloadData on a Component that had a timer setup and was re-mounted", () => {
44
- reloadData.mockReset();
45
-
46
- // it is not called before rendering hook"
47
- expect(reloadData).not.toBeCalled();
48
-
49
- // it is not called when rendering new component (Not previously rendered)
50
- renderHook(() =>
51
- useFeedRefresh({ reloadData, component: { ...component, id: "bar" } })
52
- );
53
-
54
- expect(reloadData).not.toBeCalled();
55
-
56
- // it is called when rendering previously rendered component",
57
- renderHook(() => useFeedRefresh({ reloadData, component }));
58
- expect(reloadData).toBeCalled();
59
- });
60
-
61
- it("Doesn't refresh data when enable_data_refreshing if false", () => {
62
- reloadData.mockReset();
63
-
64
- renderHook(() =>
65
- useFeedRefresh({
66
- reloadData,
67
- component: { ...component, rules: { enable_data_refreshing: false } },
68
- })
69
- );
70
-
71
- jest.runOnlyPendingTimers();
72
-
73
- expect(reloadData).not.toBeCalled();
74
- });
75
- });
@@ -1,65 +0,0 @@
1
- import * as React from "react";
2
- import { path, max } from "ramda";
3
- import { isTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
4
- import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
5
- import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
6
-
7
- import { reactHooksLogger } from "../logger";
8
- import { ReloadDataFunction } from "./useFeedLoader";
9
-
10
- export const feedRefreshLogger = reactHooksLogger.addSubsystem("feed-refresh");
11
-
12
- type Props = {
13
- reloadData?: ReloadDataFunction;
14
- component: ZappUIComponent;
15
- };
16
-
17
- const previousTimersMap = {};
18
- const minimumRefreshingInterval = 5;
19
- const defaultRefreshInterval = 60;
20
-
21
- export const useFeedRefresh = ({ reloadData, component }: Props): void => {
22
- const isDataRefreshingEnabled = isTrue(
23
- path(["rules", "enable_data_refreshing"], component)
24
- );
25
-
26
- const refreshing_interval = toNumberWithDefault(
27
- defaultRefreshInterval,
28
- component?.rules?.refreshing_interval
29
- );
30
-
31
- const refreshingIntervalInMilliseconds =
32
- max(refreshing_interval, minimumRefreshingInterval) * 1000;
33
-
34
- const isScreenActive = useIsScreenActive();
35
-
36
- React.useEffect(() => {
37
- if (isDataRefreshingEnabled && refreshing_interval && isScreenActive) {
38
- if (refreshing_interval < minimumRefreshingInterval) {
39
- feedRefreshLogger.warning({
40
- message: `You set your feed refresh interval to ${refreshing_interval} when minimum value is ${minimumRefreshingInterval}seconds.Your feed will refresh after ${minimumRefreshingInterval}seconds.`,
41
- });
42
- }
43
-
44
- if (!reloadData || typeof reloadData !== "function") {
45
- feedRefreshLogger.warning({
46
- message:
47
- "reloadData function is undefined, feed refresh feature won't work properly",
48
- });
49
- }
50
-
51
- if (previousTimersMap[component?.id]) {
52
- reloadData?.();
53
- }
54
-
55
- const refreshInterval = setInterval(() => {
56
- reloadData?.();
57
- }, refreshingIntervalInMilliseconds);
58
-
59
- return () => {
60
- previousTimersMap[component?.id] = true;
61
- clearInterval(refreshInterval);
62
- };
63
- }
64
- }, [reloadData, isScreenActive]);
65
- };