@applicaster/quick-brick-core 16.0.0-rc.53 → 16.0.0-rc.54

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.
@@ -24,11 +24,13 @@ export interface ToastStyle {
24
24
  letterSpacing?: number;
25
25
  }
26
26
 
27
+ export const DEFAULT_TOAST_TIMEOUT = 4000;
28
+
27
29
  export interface ToastPayload {
28
30
  id?: string;
29
31
  message: string;
30
32
  extraMessage?: string; // secondary line; TV renderers show it as a subtitle, mobile ignores it
31
- timeout?: number; // ms; if omitted, toast stays until dismissed
33
+ timeout?: number; // ms; defaults to DEFAULT_TOAST_TIMEOUT (4000) if omitted
32
34
  style?: ToastStyle;
33
35
  [key: string]: unknown;
34
36
  }
@@ -122,7 +124,11 @@ class NotificationToastManager {
122
124
  };
123
125
 
124
126
  private handleShowToast = (payload: ToastPayload) => {
125
- const item = { ...payload, id: payload.id ?? String(this.nextId++) };
127
+ const item = {
128
+ ...payload,
129
+ id: payload.id ?? String(this.nextId++),
130
+ timeout: payload.timeout ?? DEFAULT_TOAST_TIMEOUT,
131
+ };
126
132
 
127
133
  const queuedIndex = this.queue.findIndex((queued) => queued.id === item.id);
128
134
 
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  notificationToastManager,
3
3
  NOTIFICATION_TOAST_EVENTS,
4
+ DEFAULT_TOAST_TIMEOUT,
4
5
  } from "../NotificationToastManager";
5
6
  import { postEvent } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
6
7
 
@@ -210,4 +211,27 @@ describe("NotificationToastManager", () => {
210
211
 
211
212
  expect(onShow).not.toHaveBeenCalled();
212
213
  });
214
+
215
+ it("defaults timeout to DEFAULT_TOAST_TIMEOUT (4000ms) when omitted and auto-hides", () => {
216
+ const onShow = jest.fn();
217
+ const onHide = jest.fn();
218
+ on(NOTIFICATION_TOAST_EVENTS.SHOW, onShow);
219
+ on(NOTIFICATION_TOAST_EVENTS.HIDE, onHide);
220
+
221
+ notificationToastManager.showToast({
222
+ message: "Added to queue",
223
+ });
224
+
225
+ expect(onShow).toHaveBeenCalledWith(
226
+ expect.objectContaining({
227
+ message: "Added to queue",
228
+ timeout: DEFAULT_TOAST_TIMEOUT,
229
+ }),
230
+ expect.any(Function)
231
+ );
232
+
233
+ jest.advanceTimersByTime(DEFAULT_TOAST_TIMEOUT);
234
+
235
+ expect(onHide).toHaveBeenCalledTimes(1);
236
+ });
213
237
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "16.0.0-rc.53",
3
+ "version": "16.0.0-rc.54",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,13 +28,13 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "16.0.0-rc.53",
32
- "@applicaster/quick-brick-core-plugins": "16.0.0-rc.53",
33
- "@applicaster/zapp-pipes-v2-client": "16.0.0-rc.53",
34
- "@applicaster/zapp-react-native-bridge": "16.0.0-rc.53",
35
- "@applicaster/zapp-react-native-redux": "16.0.0-rc.53",
36
- "@applicaster/zapp-react-native-ui-components": "16.0.0-rc.53",
37
- "@applicaster/zapp-react-native-utils": "16.0.0-rc.53",
31
+ "@applicaster/applicaster-types": "16.0.0-rc.54",
32
+ "@applicaster/quick-brick-core-plugins": "16.0.0-rc.54",
33
+ "@applicaster/zapp-pipes-v2-client": "16.0.0-rc.54",
34
+ "@applicaster/zapp-react-native-bridge": "16.0.0-rc.54",
35
+ "@applicaster/zapp-react-native-redux": "16.0.0-rc.54",
36
+ "@applicaster/zapp-react-native-ui-components": "16.0.0-rc.54",
37
+ "@applicaster/zapp-react-native-utils": "16.0.0-rc.54",
38
38
  "atob": "^2.1.2",
39
39
  "axios": "^0.28.0",
40
40
  "btoa": "^1.2.1",