@tugitark/react-widget 1.1.0 → 1.2.1
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/index.js +25 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8,25 +8,43 @@ function Widget(props) {
|
|
|
8
8
|
// Is this the first time this component has been rendered ever?
|
|
9
9
|
const [firstTime, setFirstTime] = useState(true);
|
|
10
10
|
|
|
11
|
-
function onNotification(hasNotification
|
|
11
|
+
function onNotification(hasNotification) {
|
|
12
12
|
if (props.jwtFn == null && props.user == null) {
|
|
13
|
-
if (firstTime) {
|
|
13
|
+
if (!firstTime) {
|
|
14
14
|
// Replicate FAQ internal behaviour at a per-component level.
|
|
15
|
-
|
|
15
|
+
return;
|
|
16
16
|
}
|
|
17
|
-
} else {
|
|
18
|
-
props.onNotification?.(hasNotification);
|
|
19
17
|
}
|
|
18
|
+
props.onNotification && props.onNotification(hasNotification);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
function onReady() {
|
|
23
22
|
if (firstTime) {
|
|
24
23
|
setFirstTime(false);
|
|
25
|
-
props.onReady
|
|
24
|
+
props.onReady && props.onReady(hasNotification);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
function onOpened() {
|
|
29
|
+
props.onOpened && props.onOpened();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function onClosed() {
|
|
33
|
+
props.onClosed && props.onClosed();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onError(e) {
|
|
37
|
+
props.onError && props.onError(e);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render({
|
|
41
|
+
...props,
|
|
42
|
+
onNotification,
|
|
43
|
+
onReady,
|
|
44
|
+
onOpened,
|
|
45
|
+
onClosed,
|
|
46
|
+
onError,
|
|
47
|
+
});
|
|
30
48
|
|
|
31
49
|
return null;
|
|
32
50
|
}
|