react-notify-sdk 1.0.17 → 1.0.18
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.
- package/dist/FadeWrapper.js +1 -1
- package/dist/NotifyProvider.js +20 -6
- package/package.json +1 -1
package/dist/FadeWrapper.js
CHANGED
|
@@ -5,7 +5,7 @@ opacity: ${(props) => (props.visible ? 1 : 0)};
|
|
|
5
5
|
animation: ${(props) => (props.visible ? fadeIn : fadeOut)} 0.3s ease forwards;
|
|
6
6
|
transition: opacity 0.3s ease;
|
|
7
7
|
position: absolute;
|
|
8
|
-
width: ${(props) => props.device === 'Mobile' ? '
|
|
8
|
+
width: ${(props) => props.device === 'Mobile' ? '95%' : props.device === 'Tablet' ? '420px' : '420px'};
|
|
9
9
|
top: ${(props) => props.message?.position === 'top' ? '24px' : ''};
|
|
10
10
|
bottom: ${(props) => props.message?.position === 'bottom' ? '24px' : ''};
|
|
11
11
|
left: 50%;
|
package/dist/NotifyProvider.js
CHANGED
|
@@ -6,6 +6,19 @@ import NotificationMessage from './NotifyMessage';
|
|
|
6
6
|
import { supabase } from './supabase/supabaseClient';
|
|
7
7
|
import useDeviceDetection from './UseDeviceDetection';
|
|
8
8
|
import FadeWrapper from './FadeWrapper';
|
|
9
|
+
// Wildcard route matching utility
|
|
10
|
+
const routeMatches = (pattern, path) => {
|
|
11
|
+
if (pattern === path)
|
|
12
|
+
return true;
|
|
13
|
+
const escapeRegex = (str) => str.replace(/([.+^=!:${}()|[\]/\\])/g, "\\$1");
|
|
14
|
+
const regexPattern = "^" + pattern.split("*").map(escapeRegex).join(".*") + "$";
|
|
15
|
+
try {
|
|
16
|
+
return new RegExp(regexPattern).test(path);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
9
22
|
export const NotifyProvider = ({ projectId,
|
|
10
23
|
//className,
|
|
11
24
|
//style,
|
|
@@ -25,11 +38,12 @@ export const NotifyProvider = ({ projectId,
|
|
|
25
38
|
.eq('project_key', projectId)
|
|
26
39
|
.eq('route', location.pathname)
|
|
27
40
|
.eq('is_active', true)
|
|
28
|
-
.order('created_at', { ascending: false })
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
.order('created_at', { ascending: false });
|
|
42
|
+
//.limit(1)
|
|
43
|
+
//.single();
|
|
44
|
+
const match = data?.find((msg) => routeMatches(msg.route, location.pathname));
|
|
45
|
+
if (match) {
|
|
46
|
+
setMessage(match);
|
|
33
47
|
setVisible(true); // Fade in
|
|
34
48
|
}
|
|
35
49
|
else {
|
|
@@ -47,7 +61,7 @@ export const NotifyProvider = ({ projectId,
|
|
|
47
61
|
table: 'feature_messages',
|
|
48
62
|
}, (payload) => {
|
|
49
63
|
const msg = payload.new;
|
|
50
|
-
if (msg.project_key === projectId && msg.route
|
|
64
|
+
if (msg.project_key === projectId && msg.is_active && routeMatches(msg.route, location.pathname)) {
|
|
51
65
|
setMessage(msg);
|
|
52
66
|
setVisible(true);
|
|
53
67
|
}
|