cozy-sharing 26.6.0 → 26.6.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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
+ ## [26.6.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@26.6.1...cozy-sharing@26.6.2) (2025-10-20)
7
+
8
+ ### Bug Fixes
9
+
10
+ - Bind fetchAllSharings before state init in SharingProvider 🐛 ([df12219](https://github.com/cozy/cozy-libs/commit/df12219852b473867e37788e74b442c792060cc8))
11
+
12
+ ## [26.6.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@26.6.0...cozy-sharing@26.6.1) (2025-10-15)
13
+
14
+ ### Bug Fixes
15
+
16
+ - Change the way to check write access of shared drive :bug: ([e75c3ba](https://github.com/cozy/cozy-libs/commit/e75c3ba6ba044639b4ab13021067e15649ecc864))
17
+
6
18
  # [26.6.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@26.5.2...cozy-sharing@26.6.0) (2025-10-09)
7
19
 
8
20
  ### Features
@@ -585,6 +585,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
585
585
 
586
586
  var onShared = props.onShared || function () {};
587
587
 
588
+ _this2.fetchAllSharings = _this2.fetchAllSharings.bind(_this2);
588
589
  _this2.state = {
589
590
  byDocId: {},
590
591
  sharings: [],
@@ -648,7 +649,6 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
648
649
  var _client = props.client;
649
650
  _this2.sharingCol = _client.collection(SHARING_DOCTYPE);
650
651
  _this2.permissionCol = _client.collection(PERMISSION_DOCTYPE);
651
- _this2.fetchAllSharings = _this2.fetchAllSharings.bind(_this2);
652
652
  return _this2;
653
653
  }
654
654
 
package/dist/state.js CHANGED
@@ -797,22 +797,6 @@ export var getSharedDocIdsBySharings = function getSharedDocIdsBySharings(sharin
797
797
  });
798
798
  return docs;
799
799
  };
800
- /**
801
- * Resolves shared drive sharing type.
802
- *
803
- * @param {object} sharing
804
- * @returns {'two-way'|'one-way'|null}
805
- */
806
-
807
- var resolveDriveSharingTypeFromRule = function resolveDriveSharingTypeFromRule(sharing) {
808
- var _sharing$attributes;
809
-
810
- if (!(sharing !== null && sharing !== void 0 && (_sharing$attributes = sharing.attributes) !== null && _sharing$attributes !== void 0 && (_sharing$attributes = _sharing$attributes.rules) !== null && _sharing$attributes !== void 0 && _sharing$attributes.length)) return null;
811
- var rule = sharing.attributes.rules[0];
812
- var dirType = getDirectorySharingType(rule);
813
- var fileType = getFileSharingType(rule);
814
- return dirType === SHARING_TYPE.TWO_WAY || fileType === SHARING_TYPE.TWO_WAY ? SHARING_TYPE.TWO_WAY : SHARING_TYPE.ONE_WAY;
815
- };
816
800
  /**
817
801
  * Computes the effective sharing type for a drive.
818
802
  *
@@ -822,15 +806,12 @@ var resolveDriveSharingTypeFromRule = function resolveDriveSharingTypeFromRule(s
822
806
  * @returns {string|null} - the sharing type
823
807
  */
824
808
 
825
-
826
809
  export var getSharedDriveSharingType = function getSharedDriveSharingType(state, driveId, instanceUri) {
827
810
  var _sharing$attributes$m;
828
811
 
829
812
  var sharing = getSharingById(state, driveId);
830
813
  if (!sharing) return null;
831
- var baseType = resolveDriveSharingTypeFromRule(sharing);
832
- if (sharing.attributes.owner) return baseType;
833
814
  var me = (_sharing$attributes$m = sharing.attributes.members) === null || _sharing$attributes$m === void 0 ? void 0 : _sharing$attributes$m.find(matchingInstanceName(instanceUri));
834
- if (!me) return baseType;
835
- return me.read_only ? SHARING_TYPE.ONE_WAY : baseType;
815
+ if (!me) return null;
816
+ return me.read_only ? SHARING_TYPE.ONE_WAY : SHARING_TYPE.TWO_WAY;
836
817
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "26.6.0",
3
+ "version": "26.6.2",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -79,5 +79,5 @@
79
79
  "sideEffects": [
80
80
  "*.css"
81
81
  ],
82
- "gitHead": "b143c00a84179ff2802d07ffce82cf46c0078e3a"
82
+ "gitHead": "5ae1ac7e1cae4b6cab7958798ef174ec1751fcaa"
83
83
  }
@@ -54,6 +54,8 @@ export class SharingProvider extends Component {
54
54
  const instanceUri = props.client.getStackClient().uri
55
55
  const documentType = props.documentType || 'Document'
56
56
  const onShared = props.onShared || (() => {})
57
+
58
+ this.fetchAllSharings = this.fetchAllSharings.bind(this)
57
59
  this.state = {
58
60
  byDocId: {},
59
61
  sharings: [],
@@ -98,8 +100,6 @@ export class SharingProvider extends Component {
98
100
  const { client } = props
99
101
  this.sharingCol = client.collection(SHARING_DOCTYPE)
100
102
  this.permissionCol = client.collection(PERMISSION_DOCTYPE)
101
-
102
- this.fetchAllSharings = this.fetchAllSharings.bind(this)
103
103
  }
104
104
 
105
105
  dispatch = action =>
package/src/state.js CHANGED
@@ -677,24 +677,6 @@ export const getSharedDocIdsBySharings = sharings => {
677
677
  return docs
678
678
  }
679
679
 
680
- /**
681
- * Resolves shared drive sharing type.
682
- *
683
- * @param {object} sharing
684
- * @returns {'two-way'|'one-way'|null}
685
- */
686
- const resolveDriveSharingTypeFromRule = sharing => {
687
- if (!sharing?.attributes?.rules?.length) return null
688
-
689
- const rule = sharing.attributes.rules[0]
690
- const dirType = getDirectorySharingType(rule)
691
- const fileType = getFileSharingType(rule)
692
-
693
- return dirType === SHARING_TYPE.TWO_WAY || fileType === SHARING_TYPE.TWO_WAY
694
- ? SHARING_TYPE.TWO_WAY
695
- : SHARING_TYPE.ONE_WAY
696
- }
697
-
698
680
  /**
699
681
  * Computes the effective sharing type for a drive.
700
682
  *
@@ -707,11 +689,8 @@ export const getSharedDriveSharingType = (state, driveId, instanceUri) => {
707
689
  const sharing = getSharingById(state, driveId)
708
690
  if (!sharing) return null
709
691
 
710
- const baseType = resolveDriveSharingTypeFromRule(sharing)
711
- if (sharing.attributes.owner) return baseType
712
-
713
692
  const me = sharing.attributes.members?.find(matchingInstanceName(instanceUri))
714
- if (!me) return baseType
693
+ if (!me) return null
715
694
 
716
- return me.read_only ? SHARING_TYPE.ONE_WAY : baseType
695
+ return me.read_only ? SHARING_TYPE.ONE_WAY : SHARING_TYPE.TWO_WAY
717
696
  }