Skip to content

Commit f1a15ed

Browse files
Version 1.2.1
2 parents 02c004d + 005e3cf commit f1a15ed

File tree

7 files changed

+60
-39
lines changed

7 files changed

+60
-39
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 1.2.1
6+
7+
### Fixed
8+
9+
- Fixed styles for tab filters
10+
- Restricted redundant verify token calls to avoid unnecessary network requests and enhance overall efficiency.
11+
512
## 1.2.0
613

714
### Added

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ Please note that the badgeStyle, window shadow and border props are only applica
208208
borderWidth?: number,
209209
borderRadius?: number,
210210
paddingY?: number,
211-
paddingX?: number
211+
paddingX?: number,
212+
tabContainerBorderWidth?: number
212213
};
213214
}
214215
```
@@ -264,11 +265,11 @@ function MyComponent() {
264265

265266
Functions | Parameters | Type | Description |
266267
----------|------------|-------|------------|
267-
markAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
268+
markAsReadByDate | options | { startDate: ISO date string, <br>isRead?: boolean } | Updates the read status of notifications. <br>startDate- To set the read status of notifications up to the specified date. <br> isRead- Filters notifications based on their read status. |
268269
markAsReadById | id | string | Set read status of a notification to true |
269270
deleteById | id | string | Delete a notification by id |
270-
deleteByDate | startDate | ISO date string | Delete all notifications until given date |
271-
markAllAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
271+
deleteByDate | options | { startDate: ISO date string, <br>isRead?: boolean } | Delete all notifications until given start date. <br>startDate- To specify the date until which notifications are deleted. <br> isRead- Filters notifications based on their read status. |
272+
markAllAsViewed | untilDate | ISO date string |Sets the viewed status of notifications to true until the given date |
272273

273274

274275
## Example

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"react": "^18.2.0",
77
"react-dom": "^18.2.0",
88
"react-scripts": "^5.0.1",
9-
"@sirenapp/react-inbox": "^1.2.0"
9+
"@sirenapp/react-inbox": "^1.2.1"
1010
},
1111
"scripts": {
1212
"dev": "PORT=9902 react-scripts start",

src/components/SirenProvider.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { createContext, useContext, useEffect, useMemo, useState } from "react";
1+
import React, { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
22

33
import { Siren } from "@sirenapp/js-sdk";
44
import type {
@@ -77,13 +77,15 @@ const SirenProvider: React.FC<SirenProvider> = ({ config, children }) => {
7777
const [siren, setSiren] = useState<Siren | null>(null);
7878
const [verificationStatus, setVerificationStatus] =
7979
useState<VerificationStatus>(VerificationStatus.PENDING);
80+
const shouldInitialize = useRef(true);
8081
let retryCount = 0;
8182

8283

8384
const [id] = useState(generateUniqueId());
8485

8586
useEffect(() => {
86-
if (config?.recipientId && config?.userToken) {
87+
if (config?.recipientId && config?.userToken && shouldInitialize.current) {
88+
shouldInitialize.current = false;
8789
stopRealTimeFetch();
8890
sendResetDataEvents();
8991
initialize();

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ export type CustomStyle = {
229229
borderRadius?: number;
230230
paddingY?: number;
231231
paddingX?: number;
232+
tabContainerBorderWidth?: number;
232233
};
233234
};
234235

src/utils/commonUtils.ts

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ export const logger = {
119119
},
120120
};
121121

122+
export const getCustomStyleValues = (customValue?: number, defaultValue?: number) => {
123+
return customValue === undefined ||
124+
customValue === null
125+
? defaultValue
126+
: customValue
127+
}
128+
122129
export const applyTheme = (
123130
theme: ThemeProps = {},
124131
mode: ThemeMode = ThemeMode.DARK,
@@ -197,7 +204,7 @@ export const applyTheme = (
197204
theme.customCard?.background ||
198205
DefaultTheme[mode].customCard.background,
199206
padding:
200-
customStyle.customCard?.padding ||
207+
customStyle.customCard?.padding ||
201208
DefaultStyle.customCard.padding,
202209
borderBottom: `${
203210
customStyle.customCard?.borderWidth ||
@@ -228,7 +235,7 @@ export const applyTheme = (
228235
theme.colors?.textColor ||
229236
DefaultTheme[mode].customCard.titleColor,
230237
fontSize:
231-
customStyle.customCard?.titleSize ||
238+
customStyle.customCard?.titleSize ||
232239
DefaultStyle.customCard.titleSize,
233240
fontWeight:
234241
customStyle.customCard?.titleFontWeight ||
@@ -261,13 +268,13 @@ export const applyTheme = (
261268
customStyle.customCard?.descriptionSize ||
262269
DefaultStyle.customCard.descriptionSize,
263270
fontWeight:
264-
customStyle.customCard?.descriptionFontWeight ||
265-
DefaultStyle.customCard.descriptionFontWeight,
271+
customStyle.customCard?.descriptionFontWeight ||
272+
DefaultStyle.customCard.descriptionFontWeight,
266273
},
267274
dateStyle: {
268275
color: theme.colors?.dateColor || DefaultTheme[mode].colors.dateColor,
269276
fontSize:
270-
customStyle.customCard?.dateSize ||
277+
customStyle.customCard?.dateSize ||
271278
DefaultStyle.customCard.dateSize,
272279
lineHeight: "16px",
273280
},
@@ -320,7 +327,7 @@ export const applyTheme = (
320327
height: customStyle.badgeStyle?.size || defaultBadgeStyle.size,
321328
backgroundColor: theme.badgeStyle?.color || defaultBadgeStyle.color,
322329
top: customStyle?.badgeStyle?.top ? `${customStyle.badgeStyle.top}px` : defaultBadgeStyle.top,
323-
right: customStyle?.badgeStyle?.right ? `${customStyle.badgeStyle.right}px` : defaultBadgeStyle.right,
330+
right: customStyle?.badgeStyle?.right ? `${customStyle.badgeStyle.right}px` : defaultBadgeStyle.right,
324331
},
325332
badgeTextStyle: {
326333
color: theme.badgeStyle?.textColor || defaultBadgeStyle.textColor,
@@ -333,35 +340,35 @@ export const applyTheme = (
333340
DefaultTheme[mode].colors.primaryColor
334341
}`,
335342
},
336-
tabsHeaderContainer:{
343+
tabsHeaderContainer: {
337344
height: customStyle.tabs?.containerHeight || DefaultStyle.tabs.containerHeight,
338345
backgroundColor: theme.tabs?.containerBackgroundColor || DefaultTheme[mode].tabs.containerBackgroundColor,
339346
borderBottom: `${
340-
customStyle.customCard?.borderWidth ||
341-
DefaultStyle.customCard.borderWidth
347+
getCustomStyleValues(customStyle.tabs?.tabContainerBorderWidth, DefaultStyle.tabs.tabContainerBorderWidth)
342348
}px solid`,
343349
borderColor:
344350
theme.customCard?.borderColor ||
345351
theme.colors?.borderColor ||
346352
DefaultTheme[mode].customCard.borderColor,
347-
padding: `0 ${customStyle.tabs?.tabPadding || DefaultStyle.tabs.tabPadding}px`,
348-
gap: customStyle.tabs?.headingGap || DefaultStyle.tabs.headingGap
349-
353+
padding: `0 ${
354+
getCustomStyleValues(customStyle.tabs?.tabPadding, DefaultStyle.tabs.tabPadding)
355+
}px`,
356+
gap: customStyle.tabs?.headingGap || DefaultStyle.tabs.headingGap,
350357
},
351358
activeTabStyle:{
352359
backgroundColor: theme.tabs?.activeTabBackgroundColor || DefaultTheme[mode].tabs.activeTabBackgroundColor,
353360
color: theme.tabs?.activeTabTextColor || DefaultTheme[mode].tabs.activeTabTextColor,
354361
fontSize: customStyle.tabs?.activeTabTextSize || DefaultStyle.tabs.activeTabTextSize,
355362
fontWeight: customStyle.tabs?.activeTabTextWeight || DefaultStyle.tabs.activeTabTextWeight,
356363
border: `${
357-
customStyle.tabs?.borderWidth ||
364+
customStyle.tabs?.borderWidth ||
358365
DefaultStyle.tabs.borderWidth
359366
}px solid`,
360367
borderColor:
361-
theme.tabs?.borderColor ||
362-
theme.colors?.borderColor ||
363-
DefaultTheme[mode].tabs?.borderColor,
364-
borderRadius: customStyle.tabs?.borderRadius ||
368+
theme.tabs?.borderColor ||
369+
theme.colors?.borderColor ||
370+
DefaultTheme[mode].tabs?.borderColor,
371+
borderRadius: customStyle.tabs?.borderRadius ||
365372
DefaultStyle.tabs.borderRadius,
366373
padding: `${customStyle.tabs?.paddingY || DefaultStyle.tabs.paddingY}px
367374
${customStyle.tabs?.paddingX || DefaultStyle.tabs.paddingX}px`,
@@ -372,23 +379,22 @@ export const applyTheme = (
372379
fontSize: customStyle.tabs?.inactiveTabTextSize || DefaultStyle.tabs.inactiveTabTextSize,
373380
fontWeight: customStyle.tabs?.inactiveTabTextWeight || DefaultStyle.tabs.inactiveTabTextWeight,
374381
border: `${
375-
customStyle.tabs?.borderWidth ||
382+
customStyle.tabs?.borderWidth ||
376383
DefaultStyle.tabs.borderWidth
377384
}px solid`,
378385
borderColor:
379-
theme.tabs?.borderColor ||
380-
theme.colors?.borderColor ||
381-
DefaultTheme[mode].tabs?.borderColor,
382-
borderRadius: customStyle.tabs?.borderRadius ||
386+
theme.tabs?.borderColor ||
387+
theme.colors?.borderColor ||
388+
DefaultTheme[mode].tabs?.borderColor,
389+
borderRadius: customStyle.tabs?.borderRadius ||
383390
DefaultStyle.tabs.borderRadius,
384391
padding: `${customStyle.tabs?.paddingY || DefaultStyle.tabs.paddingY}px
385392
${customStyle.tabs?.paddingX || DefaultStyle.tabs.paddingX}px`,
386393
},
387394
activeTabIndicator:{
388395
backgroundColor: theme.tabs?.indicatorColor || DefaultTheme[mode].tabs.indicatorColor,
389-
height: (customStyle.tabs?.indicatorHeight === undefined || customStyle.tabs?.indicatorHeight === null) ?
390-
DefaultStyle.tabs.indicatorHeight : customStyle.tabs?.indicatorHeight,
391-
}
396+
height: getCustomStyleValues(customStyle.tabs?.indicatorHeight, DefaultStyle.tabs.indicatorHeight)
397+
},
392398
};
393399
};
394400

@@ -429,7 +435,7 @@ export const generateFilterParams = (
429435
if (fromStart) params = { ...params, start: data[0].createdAt };
430436
else params = { ...params, end: data[data.length - 1].createdAt };
431437

432-
if (filterType === Tabs.UNREAD) params = { ...params, isRead: false};
438+
if (filterType === Tabs.UNREAD) params = { ...params, isRead: false };
433439

434440
return params;
435441
};
@@ -483,7 +489,6 @@ export const calculateModalWidth = (containerWidth: DimensionValue): number => {
483489
return modalWidth;
484490
};
485491

486-
487492
export const debounce = <F extends (...args: unknown[]) => void>(
488493
func: F,
489494
delay: number
@@ -498,22 +503,26 @@ export const debounce = <F extends (...args: unknown[]) => void>(
498503
};
499504
};
500505

501-
export const getModalContentHeightInFullScreen = (headerHeight: DimensionValue | undefined) => {
506+
export const getModalContentHeightInFullScreen = (
507+
headerHeight: DimensionValue | undefined
508+
) => {
502509
let updatedHeight = 0;
503510

504511
if (typeof headerHeight === "string")
505512
updatedHeight = parseInt(headerHeight.slice(0, -2));
506513
else if (typeof headerHeight === "number") updatedHeight = headerHeight;
507514

508-
return `calc(100% - ${updatedHeight}px)`
515+
return `calc(100% - ${updatedHeight}px)`;
509516
};
510517

511518
export const generateUniqueId = (): string => {
512519
return Math.random().toString(36).substring(2, 15);
513520
};
514521

515-
export const mergeStyles = (...styleObjects: CSSProperties[]): CSSProperties => {
522+
export const mergeStyles = (
523+
...styleObjects: CSSProperties[]
524+
): CSSProperties => {
516525
return styleObjects.reduce((mergedStyles, currentStyle) => {
517526
return { ...mergedStyles, ...currentStyle };
518527
}, {});
519-
};
528+
};

src/utils/defaultStyles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ const defaultStyles = {
6161
borderWidth: 0,
6262
borderRadius: 0,
6363
paddingX: 10,
64-
paddingY: 5
64+
paddingY: 5,
65+
tabContainerBorderWidth: 0.5,
6566
}
6667
}
6768

0 commit comments

Comments
 (0)