cozy-sharing 10.4.0 → 10.4.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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
+ ## [10.4.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@10.4.0...cozy-sharing@10.4.1) (2024-03-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Remove scenario where sharingModal lose state ([43e583a](https://github.com/cozy/cozy-libs/commit/43e583a64855898c009972c52d66efc408c3d1d4))
12
+
13
+
14
+
15
+
16
+
6
17
  # [10.4.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@10.3.0...cozy-sharing@10.4.0) (2024-02-29)
7
18
 
8
19
 
@@ -1,5 +1,15 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+
4
+ /**
5
+ * Fetches the file paths for the given files.
6
+ * Should not be used for directories.
7
+ *
8
+ * @param {Object} client - The cozy-client instance.
9
+ * @param {string} doctype - The type of document.
10
+ * @param {Array} files - The array of files.
11
+ * @returns {Promise<Array>} - The array of file paths.
12
+ */
3
13
  export var fetchFilesPaths = /*#__PURE__*/function () {
4
14
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(client, doctype, files) {
5
15
  var parentDirIds, parentDirs, filePaths;
@@ -13,30 +13,40 @@ export var useFetchDocumentPath = function useFetchDocumentPath(client, document
13
13
  ;
14
14
 
15
15
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
16
- var path;
16
+ var isDirectory, path;
17
17
  return _regeneratorRuntime.wrap(function _callee$(_context) {
18
18
  while (1) switch (_context.prev = _context.next) {
19
19
  case 0:
20
20
  _context.prev = 0;
21
- _context.next = 3;
21
+ isDirectory = document.type === 'directory';
22
+
23
+ if (!isDirectory) {
24
+ _context.next = 4;
25
+ break;
26
+ }
27
+
28
+ return _context.abrupt("return", setDocumentPath(document.path));
29
+
30
+ case 4:
31
+ _context.next = 6;
22
32
  return fetchFilesPaths(client, document._type, [document]);
23
33
 
24
- case 3:
34
+ case 6:
25
35
  path = _context.sent;
26
36
  setDocumentPath(path[0]); // eslint-disable-next-line
27
37
 
28
- _context.next = 9;
38
+ _context.next = 12;
29
39
  break;
30
40
 
31
- case 7:
32
- _context.prev = 7;
41
+ case 10:
42
+ _context.prev = 10;
33
43
  _context.t0 = _context["catch"](0);
34
44
 
35
- case 9:
45
+ case 12:
36
46
  case "end":
37
47
  return _context.stop();
38
48
  }
39
- }, _callee, null, [[0, 7]]);
49
+ }, _callee, null, [[0, 10]]);
40
50
  }))();
41
51
  }, [client, document]);
42
52
  return documentPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "10.4.0",
3
+ "version": "10.4.1",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -21,7 +21,8 @@
21
21
  "prepublishOnly": "yarn build",
22
22
  "test": "env NODE_ENV=test jest --env=jest-environment-jsdom-sixteen",
23
23
  "lint": "cd .. && yarn eslint --ext js,jsx packages/cozy-sharing",
24
- "watch": "yarn build --watch",
24
+ "start": "yarn build --watch",
25
+ "watch": "yarn run start",
25
26
  "watch:doc:react": "(cd ../.. && TARGET=cozy-sharing yarn watch:doc:react)"
26
27
  },
27
28
  "dependencies": {
@@ -60,5 +61,5 @@
60
61
  "sideEffects": [
61
62
  "*.css"
62
63
  ],
63
- "gitHead": "e3e6b6ca27bfcc2c61893eeb763c43f926308630"
64
+ "gitHead": "d891debd980b3b73435e77f0c1ea878cfea67037"
64
65
  }
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Fetches the file paths for the given files.
3
+ * Should not be used for directories.
4
+ *
5
+ * @param {Object} client - The cozy-client instance.
6
+ * @param {string} doctype - The type of document.
7
+ * @param {Array} files - The array of files.
8
+ * @returns {Promise<Array>} - The array of file paths.
9
+ */
1
10
  export const fetchFilesPaths = async (client, doctype, files) => {
2
11
  const parentDirIds = files
3
12
  .map(f => f.dir_id)
@@ -9,6 +9,10 @@ export const useFetchDocumentPath = (client, document) => {
9
9
  useEffect(() => {
10
10
  ;(async () => {
11
11
  try {
12
+ const isDirectory = document.type === 'directory'
13
+
14
+ if (isDirectory) return setDocumentPath(document.path)
15
+
12
16
  const path = await fetchFilesPaths(client, document._type, [document])
13
17
  setDocumentPath(path[0])
14
18
  // eslint-disable-next-line