@veltdev/react 4.6.0-beta.6 → 4.6.0-beta.7

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/cjs/index.js CHANGED
@@ -145,13 +145,13 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain, integ
145
145
  }
146
146
  };
147
147
 
148
- var VELT_SDK_VERSION = '4.6.0-beta.6';
148
+ var VELT_SDK_VERSION = '4.6.0-beta.7';
149
149
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
150
150
  var VELT_TAB_ID = 'veltTabId';
151
151
  // integrity map for the Velt SDK
152
152
  // Note: generate integrity hashes with: https://www.srihash.org/
153
153
  var INTEGRITY_MAP = {
154
- '4.6.0-beta.6': 'sha384-EH2kQ0XdRJL2vanBz2dNvhGLWz+a+5DP3FQjtDRr7/1mosqpFC8URa8kRiaQBvFs',
154
+ '4.6.0-beta.7': 'sha384-w7F4QM2nNj2v5ZjTBq2peyUCcChvMfpzYSEqmq3ekczFcfnIEccUjocPIp9EkDOm',
155
155
  };
156
156
 
157
157
  var validProps = ['veltIf', 'veltClass', 'className', 'variant'];
@@ -6258,6 +6258,31 @@ function useHeartbeat(heartbeatConfig) {
6258
6258
  }, [client === null || client === void 0 ? void 0 : client.getHeartbeat, memoizedConfig]);
6259
6259
  return data;
6260
6260
  }
6261
+ function useCurrentUser() {
6262
+ var client = useVeltClient().client;
6263
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
6264
+ var subscriptionRef = React__default["default"].useRef();
6265
+ React__default["default"].useEffect(function () {
6266
+ if (!(client === null || client === void 0 ? void 0 : client.getCurrentUser))
6267
+ return;
6268
+ // Unsubscribe from the previous subscription if it exists
6269
+ if (subscriptionRef.current) {
6270
+ subscriptionRef.current.unsubscribe();
6271
+ }
6272
+ var subscription = client.getCurrentUser().subscribe(function (res) {
6273
+ setData(res);
6274
+ });
6275
+ // Store the new subscription
6276
+ subscriptionRef.current = subscription;
6277
+ // Cleanup function.
6278
+ return function () {
6279
+ if (subscriptionRef.current) {
6280
+ subscriptionRef.current.unsubscribe();
6281
+ }
6282
+ };
6283
+ }, [client === null || client === void 0 ? void 0 : client.getCurrentUser]);
6284
+ return data;
6285
+ }
6261
6286
 
6262
6287
  function useCommentUtils() {
6263
6288
  var _a = React__default["default"].useState(), commentElement = _a[0], setCommentElement = _a[1];
@@ -8103,6 +8128,7 @@ exports.useContactList = useContactList;
8103
8128
  exports.useContactSelected = useContactSelected;
8104
8129
  exports.useContactUtils = useContactUtils;
8105
8130
  exports.useCopyLink = useCopyLink;
8131
+ exports.useCurrentUser = useCurrentUser;
8106
8132
  exports.useCursorUsers = useCursorUsers;
8107
8133
  exports.useCursorUtils = useCursorUtils;
8108
8134
  exports.useDeleteAttachment = useDeleteAttachment;