@hocuspocus/provider 2.9.2-rc.0 → 2.10.0

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.
@@ -1751,9 +1751,10 @@ class HocuspocusProviderWebsocket extends EventEmitter {
1751
1751
  this.receivedOnStatusPayload = data;
1752
1752
  }
1753
1753
  attach(provider) {
1754
+ let connectPromise;
1754
1755
  this.configuration.providerMap.set(provider.configuration.name, provider);
1755
1756
  if (this.status === WebSocketStatus.Disconnected && this.shouldConnect) {
1756
- this.connect();
1757
+ connectPromise = this.connect();
1757
1758
  }
1758
1759
  if (this.receivedOnOpenPayload) {
1759
1760
  provider.onOpen(this.receivedOnOpenPayload);
@@ -1761,6 +1762,7 @@ class HocuspocusProviderWebsocket extends EventEmitter {
1761
1762
  if (this.receivedOnStatusPayload) {
1762
1763
  provider.onStatus(this.receivedOnStatusPayload);
1763
1764
  }
1765
+ return connectPromise;
1764
1766
  }
1765
1767
  detach(provider) {
1766
1768
  this.configuration.providerMap.delete(provider.configuration.name);
@@ -2594,7 +2596,8 @@ class HocuspocusProvider extends EventEmitter {
2594
2596
  if (this.configuration.broadcast) {
2595
2597
  this.subscribeToBroadcastChannel();
2596
2598
  }
2597
- return this.configuration.websocketProvider.connect();
2599
+ this.configuration.websocketProvider.shouldConnect = true;
2600
+ return this.configuration.websocketProvider.attach(this);
2598
2601
  }
2599
2602
  disconnect() {
2600
2603
  this.disconnectBroadcastChannel();
@@ -2903,7 +2906,12 @@ class TiptapCollabProvider extends HocuspocusProvider {
2903
2906
  return null;
2904
2907
  }
2905
2908
  thread.set('updatedAt', (new Date()).toISOString());
2906
- thread.set('data', data.data);
2909
+ if (data.data) {
2910
+ thread.set('data', data.data);
2911
+ }
2912
+ if (data.resolvedAt || data.resolvedAt === null) {
2913
+ thread.set('resolvedAt', data.resolvedAt);
2914
+ }
2907
2915
  return thread.toJSON();
2908
2916
  }
2909
2917
  deleteThread(id) {
@@ -2955,8 +2963,12 @@ class TiptapCollabProvider extends HocuspocusProvider {
2955
2963
  if (comment === null)
2956
2964
  return null;
2957
2965
  comment.set('updatedAt', (new Date()).toISOString());
2958
- comment.set('data', data.data);
2959
- comment.set('content', data.content);
2966
+ if (data.data) {
2967
+ comment.set('data', data.data);
2968
+ }
2969
+ if (data.content) {
2970
+ comment.set('content', data.content);
2971
+ }
2960
2972
  return thread.toJSON();
2961
2973
  }
2962
2974
  deleteComment(threadId, commentId) {