@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.
@@ -1775,9 +1775,10 @@ class HocuspocusProviderWebsocket extends EventEmitter {
1775
1775
  this.receivedOnStatusPayload = data;
1776
1776
  }
1777
1777
  attach(provider) {
1778
+ let connectPromise;
1778
1779
  this.configuration.providerMap.set(provider.configuration.name, provider);
1779
1780
  if (this.status === exports.WebSocketStatus.Disconnected && this.shouldConnect) {
1780
- this.connect();
1781
+ connectPromise = this.connect();
1781
1782
  }
1782
1783
  if (this.receivedOnOpenPayload) {
1783
1784
  provider.onOpen(this.receivedOnOpenPayload);
@@ -1785,6 +1786,7 @@ class HocuspocusProviderWebsocket extends EventEmitter {
1785
1786
  if (this.receivedOnStatusPayload) {
1786
1787
  provider.onStatus(this.receivedOnStatusPayload);
1787
1788
  }
1789
+ return connectPromise;
1788
1790
  }
1789
1791
  detach(provider) {
1790
1792
  this.configuration.providerMap.delete(provider.configuration.name);
@@ -2618,7 +2620,8 @@ class HocuspocusProvider extends EventEmitter {
2618
2620
  if (this.configuration.broadcast) {
2619
2621
  this.subscribeToBroadcastChannel();
2620
2622
  }
2621
- return this.configuration.websocketProvider.connect();
2623
+ this.configuration.websocketProvider.shouldConnect = true;
2624
+ return this.configuration.websocketProvider.attach(this);
2622
2625
  }
2623
2626
  disconnect() {
2624
2627
  this.disconnectBroadcastChannel();
@@ -2927,7 +2930,12 @@ class TiptapCollabProvider extends HocuspocusProvider {
2927
2930
  return null;
2928
2931
  }
2929
2932
  thread.set('updatedAt', (new Date()).toISOString());
2930
- thread.set('data', data.data);
2933
+ if (data.data) {
2934
+ thread.set('data', data.data);
2935
+ }
2936
+ if (data.resolvedAt || data.resolvedAt === null) {
2937
+ thread.set('resolvedAt', data.resolvedAt);
2938
+ }
2931
2939
  return thread.toJSON();
2932
2940
  }
2933
2941
  deleteThread(id) {
@@ -2979,8 +2987,12 @@ class TiptapCollabProvider extends HocuspocusProvider {
2979
2987
  if (comment === null)
2980
2988
  return null;
2981
2989
  comment.set('updatedAt', (new Date()).toISOString());
2982
- comment.set('data', data.data);
2983
- comment.set('content', data.content);
2990
+ if (data.data) {
2991
+ comment.set('data', data.data);
2992
+ }
2993
+ if (data.content) {
2994
+ comment.set('content', data.content);
2995
+ }
2984
2996
  return thread.toJSON();
2985
2997
  }
2986
2998
  deleteComment(threadId, commentId) {