@tugitark/react-widget 1.3.0 → 1.3.2

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.
Files changed (2) hide show
  1. package/index.js +7 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,12 +4,14 @@ import { useState, useCallback } from 'react';
4
4
 
5
5
  import render from '@tugitark/declarative-widget';
6
6
 
7
- function Widget({ onNotification, onReady, onOpened, onClosed, onError, ...props }) {
7
+ function Widget({ onNotification, onReady, ...props }) {
8
8
  // Is this the first time this component has been rendered ever?
9
9
  const [firstTime, setFirstTime] = useState(true);
10
+
11
+ // Is this the free (FAQ) version of the widget?
10
12
  const isFree = props.jwtFn == null && props.user == null;
11
13
 
12
- const onNotification_ = useCallback((hasNotification) => {
14
+ props.onNotification = useCallback((hasNotification) => {
13
15
  if (isFree && !firstTime) {
14
16
  // Replicate FAQ internal behaviour at a per-component level.
15
17
  return;
@@ -17,25 +19,15 @@ function Widget({ onNotification, onReady, onOpened, onClosed, onError, ...props
17
19
  onNotification && onNotification(hasNotification);
18
20
  }, [onNotification, firstTime, isFree]);
19
21
 
20
- rest.onReady = useCallback(() => {
22
+ props.onReady = useCallback(() => {
23
+ // This is called every time the widget re-mounts internally. However, we only want to
24
+ // notify the caller the first time it re-mounts after this component was created.
21
25
  if (firstTime) {
22
26
  setFirstTime(false);
23
27
  onReady && onReady();
24
28
  }
25
29
  }, [onReady, firstTime]);
26
30
 
27
- rest.onOpened = useCallback(() => {
28
- onOpened && onOpened();
29
- }, [onOpened]);
30
-
31
- rest.onClosed = useCallback(() => {
32
- onClosed && onClosed();
33
- }, [onClosed]);
34
-
35
- rest.onError = useCallback((e) => {
36
- onError && onError(e);
37
- }, [onError]);
38
-
39
31
  render(props);
40
32
 
41
33
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tugitark/react-widget",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Wraps the tugitark widget in a React component.",
5
5
  "scripts": {
6
6
  "release": "npm publish --access public"