cozy-external-bridge 0.12.0 → 0.12.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.
@@ -45,6 +45,7 @@ var useListenBridgeRequests = function useListenBridgeRequests(origin) {
45
45
  setIsReady = _useState2[1];
46
46
 
47
47
  (0, _react.useEffect)(function () {
48
+ if (isReady) return;
48
49
  if (!client) return;
49
50
  var exposedMethods = {
50
51
  // Proof of concepts of Twake <-> Cozy communication
@@ -118,7 +119,7 @@ var useListenBridgeRequests = function useListenBridgeRequests(origin) {
118
119
  }(),
119
120
  updateDocs: function () {
120
121
  var _updateDocs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref4) {
121
- var docsId, content, _ref5, file, _ref6, uploadedFile;
122
+ var docsId, content, _ref5, files, file, _ref6, uploadedFile;
122
123
 
123
124
  return _regenerator.default.wrap(function _callee3$(_context3) {
124
125
  while (1) {
@@ -128,13 +129,15 @@ var useListenBridgeRequests = function useListenBridgeRequests(origin) {
128
129
  _context3.next = 3;
129
130
  return client.query((0, _cozyClient.Q)('io.cozy.files').where({
130
131
  'metadata.externalId': docsId
131
- }));
132
+ }).indexFields(['metadata.externalId']).limitBy(1), {
133
+ as: "io.cozy.files/".concat(docsId)
134
+ });
132
135
 
133
136
  case 3:
134
137
  _ref5 = _context3.sent;
135
- file = _ref5.data;
138
+ files = _ref5.data;
136
139
 
137
- if (file) {
140
+ if (!(!files || files.length < 1)) {
138
141
  _context3.next = 7;
139
142
  break;
140
143
  }
@@ -142,18 +145,22 @@ var useListenBridgeRequests = function useListenBridgeRequests(origin) {
142
145
  return _context3.abrupt("return");
143
146
 
144
147
  case 7:
145
- _context3.next = 9;
148
+ file = files[0]; // eslint-disable-next-line @typescript-eslint/no-unsafe-call
149
+
150
+ _context3.next = 10;
146
151
  return client.collection('io.cozy.files') // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
147
152
  .updateFile(content, {
148
- fileId: file._id
153
+ fileId: file._id,
154
+ name: file.name,
155
+ metadata: file.metadata
149
156
  });
150
157
 
151
- case 9:
158
+ case 10:
152
159
  _ref6 = _context3.sent;
153
160
  uploadedFile = _ref6.data;
154
161
  return _context3.abrupt("return", uploadedFile);
155
162
 
156
- case 12:
163
+ case 13:
157
164
  case "end":
158
165
  return _context3.stop();
159
166
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cozy-external-bridge",
3
3
  "description": "Library allows communication between a container app and an app embedded in an iframe",
4
- "version": "0.12.0",
4
+ "version": "0.12.2",
5
5
  "author": {
6
6
  "name": "Cozy Cloud",
7
7
  "url": "https://github.com/cozy"
@@ -68,5 +68,5 @@
68
68
  "lint": "cd ../.. && yarn eslint --ext js,jsx,ts packages/cozy-external-bridge"
69
69
  },
70
70
  "types": "dist/index.d.ts",
71
- "gitHead": "f29baff64417849e386f23c3d5e04577467a303d"
71
+ "gitHead": "ffe870398b20e8c48dbf8cd5c0b169f5f973c8a3"
72
72
  }