cozy-harvest-lib 9.32.2 → 9.32.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [9.32.4](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.32.3...cozy-harvest-lib@9.32.4) (2022-12-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Do not use CozyRealtime.unsubscribeAll anymore ([dc6d942](https://github.com/cozy/cozy-libs/commit/dc6d9423a4b49d5e11ddb6c7620cca9541c22519))
12
+
13
+
14
+
15
+
16
+
17
+ ## [9.32.3](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.32.2...cozy-harvest-lib@9.32.3) (2022-12-05)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **harvest:** Use correct button to close CozyConfirmDialog ([cd7e22b](https://github.com/cozy/cozy-libs/commit/cd7e22bdb9c5f7addacb1230e788b4a3a03c1126))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [9.32.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.32.1...cozy-harvest-lib@9.32.2) (2022-12-02)
7
29
 
8
30
 
@@ -1,7 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import React, { createContext, useContext, useState } from 'react';
4
- import Buttons from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons';
4
+ import Button from 'cozy-ui/transpiled/react/Buttons';
5
5
  import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
6
6
  export var CozyConfirmDialogContext = /*#__PURE__*/createContext();
7
7
  var currentDialogId = 0;
@@ -55,21 +55,20 @@ export var CozyConfirmDialogProvider = /*#__PURE__*/React.memo(function (props)
55
55
  value: context
56
56
  }, dialogs && dialogs.map(function (dialog) {
57
57
  return /*#__PURE__*/React.createElement(ConfirmDialog, {
58
- key: dialog.id,
59
58
  open: true,
59
+ key: dialog.id,
60
60
  title: dialog.title,
61
61
  content: dialog.description,
62
- onClose: function onClose() {
63
- return _onClose(dialog.id);
64
- },
65
- actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Buttons, {
66
- variant: "text",
67
- color: "primary",
62
+ actions: /*#__PURE__*/React.createElement(Button, {
63
+ label: dialog.closeLabel,
68
64
  "aria-label": "Close dialog",
69
65
  onClick: function onClick() {
70
66
  return _onClose(dialog.id);
71
67
  }
72
- }, dialog.closeLabel))
68
+ }),
69
+ onClose: function onClose() {
70
+ return _onClose(dialog.id);
71
+ }
73
72
  });
74
73
  }), children);
75
74
  });
@@ -364,7 +364,7 @@ function registerRealtime(_ref4) {
364
364
  var realtime = client.plugins.realtime;
365
365
  realtime.subscribe('notified', 'io.cozy.accounts', OAUTH_REALTIME_CHANNEL, handleRealtime(konnector, resolve));
366
366
  return function () {
367
- return realtime.unsubscribeAll();
367
+ return realtime.unsubscribe('notified', 'io.cozy.accounts', OAUTH_REALTIME_CHANNEL, handleRealtime(konnector, resolve));
368
368
  };
369
369
  };
370
370
  }
@@ -37,7 +37,7 @@ function CozyRealtimeMock() {
37
37
  this.subscribe = jest.fn().mockImplementation(function (eventType, doctype, channel, fn) {
38
38
  _this.on(eventType + doctype + channel, fn);
39
39
  });
40
- this.unsubscribeAll = jest.fn().mockImplementation(function () {
40
+ this.unsubscribe = jest.fn().mockImplementation(function () {
41
41
  _this.removeAllListeners();
42
42
  });
43
43
 
@@ -50,7 +50,7 @@ function CozyRealtimeMock() {
50
50
 
51
51
  _this.subscribe.mockClear();
52
52
 
53
- _this.unsubscribeAll.mockClear();
53
+ _this.unsubscribe.mockClear();
54
54
  };
55
55
  }
56
56
 
@@ -1089,9 +1089,15 @@ export var ConnectionFlow = /*#__PURE__*/function () {
1089
1089
  this.unsubscribeAllRealtime = function () {
1090
1090
  _this3.jobWatcher.unsubscribeAll();
1091
1091
 
1092
- _this3.realtime.unsubscribeAll();
1092
+ _this3.unsubscribeAllConnectionFlowRealtime();
1093
1093
  };
1094
1094
  }
1095
+ }, {
1096
+ key: "unsubscribeAllConnectionFlowRealtime",
1097
+ value: function unsubscribeAllConnectionFlowRealtime() {
1098
+ this.realtime.unsubscribe('updated', JOBS_DOCTYPE, this.handleTriggerJobUpdated);
1099
+ this.realtime.unsubscribe('updated', JOBS_DOCTYPE, this.job._id, this.handleCurrentJobUpdated.bind(this));
1100
+ }
1095
1101
  }, {
1096
1102
  key: "unwatch",
1097
1103
  value: function unwatch() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "9.32.2",
3
+ "version": "9.32.4",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -91,5 +91,5 @@
91
91
  "react-router-dom": "^5.0.1"
92
92
  },
93
93
  "sideEffects": false,
94
- "gitHead": "17af5df3d39fd8b3bc37aa6f421ec0dd1c97b787"
94
+ "gitHead": "e05c102ddedafe5162d5f01f398c0d9655340321"
95
95
  }
@@ -1,5 +1,6 @@
1
1
  import React, { createContext, useContext, useState } from 'react'
2
- import Buttons from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons'
2
+
3
+ import Button from 'cozy-ui/transpiled/react/Buttons'
3
4
  import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
4
5
 
5
6
  export const CozyConfirmDialogContext = createContext()
@@ -19,12 +20,14 @@ export const useCozyConfirmDialog = () => {
19
20
  export const CozyConfirmDialogProvider = React.memo(props => {
20
21
  const [dialogs, setDialogs] = useState([])
21
22
  const { children } = props
23
+
22
24
  const onClose = dialogId => {
23
25
  dialogs.find(dialog => dialog.id === dialogId).callback()
24
26
  setDialogs(prevDialogs =>
25
27
  prevDialogs.filter(dialog => dialog.id !== dialogId)
26
28
  )
27
29
  }
30
+
28
31
  const context = {
29
32
  showDialog: ({ title, closeLabel, description }) => {
30
33
  return new Promise(resolve => {
@@ -43,29 +46,25 @@ export const CozyConfirmDialogProvider = React.memo(props => {
43
46
  })
44
47
  }
45
48
  }
49
+
46
50
  return (
47
51
  <CozyConfirmDialogContext.Provider value={context}>
48
52
  {dialogs &&
49
53
  dialogs.map(dialog => {
50
54
  return (
51
55
  <ConfirmDialog
56
+ open
52
57
  key={dialog.id}
53
- open={true}
54
58
  title={dialog.title}
55
59
  content={dialog.description}
56
- onClose={() => onClose(dialog.id)}
57
60
  actions={
58
- <>
59
- <Buttons
60
- variant="text"
61
- color="primary"
62
- aria-label="Close dialog"
63
- onClick={() => onClose(dialog.id)}
64
- >
65
- {dialog.closeLabel}
66
- </Buttons>
67
- </>
61
+ <Button
62
+ label={dialog.closeLabel}
63
+ aria-label="Close dialog"
64
+ onClick={() => onClose(dialog.id)}
65
+ />
68
66
  }
67
+ onClose={() => onClose(dialog.id)}
69
68
  />
70
69
  )
71
70
  })}
@@ -256,7 +256,13 @@ function registerRealtime({ client, konnector }) {
256
256
  OAUTH_REALTIME_CHANNEL,
257
257
  handleRealtime(konnector, resolve)
258
258
  )
259
- return () => realtime.unsubscribeAll()
259
+ return () =>
260
+ realtime.unsubscribe(
261
+ 'notified',
262
+ 'io.cozy.accounts',
263
+ OAUTH_REALTIME_CHANNEL,
264
+ handleRealtime(konnector, resolve)
265
+ )
260
266
  }
261
267
  }
262
268
 
@@ -30,7 +30,7 @@ function CozyRealtimeMock() {
30
30
  .mockImplementation((eventType, doctype, channel, fn) => {
31
31
  this.on(eventType + doctype + channel, fn)
32
32
  })
33
- this.unsubscribeAll = jest.fn().mockImplementation(() => {
33
+ this.unsubscribe = jest.fn().mockImplementation(() => {
34
34
  this.removeAllListeners()
35
35
  })
36
36
 
@@ -41,7 +41,7 @@ function CozyRealtimeMock() {
41
41
  this.clear = () => {
42
42
  this.removeAllListeners()
43
43
  this.subscribe.mockClear()
44
- this.unsubscribeAll.mockClear()
44
+ this.unsubscribe.mockClear()
45
45
  }
46
46
  }
47
47
  MicroEE.mixin(CozyRealtimeMock)
@@ -710,10 +710,25 @@ export class ConnectionFlow {
710
710
 
711
711
  this.unsubscribeAllRealtime = () => {
712
712
  this.jobWatcher.unsubscribeAll()
713
- this.realtime.unsubscribeAll()
713
+ this.unsubscribeAllConnectionFlowRealtime()
714
714
  }
715
715
  }
716
716
 
717
+ unsubscribeAllConnectionFlowRealtime() {
718
+ this.realtime.unsubscribe(
719
+ 'updated',
720
+ JOBS_DOCTYPE,
721
+ this.handleTriggerJobUpdated
722
+ )
723
+
724
+ this.realtime.unsubscribe(
725
+ 'updated',
726
+ JOBS_DOCTYPE,
727
+ this.job._id,
728
+ this.handleCurrentJobUpdated.bind(this)
729
+ )
730
+ }
731
+
717
732
  unwatch() {
718
733
  if (typeof this.unsubscribeAllRealtime === 'function') {
719
734
  this.unsubscribeAllRealtime()