core-3nweb-client-lib 0.43.15 → 0.43.16

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.
@@ -1469,20 +1469,24 @@ declare namespace web3n.files {
1469
1469
  interface RemoteVersionArchivalEvent extends FSEvent {
1470
1470
  type: 'remote-version-archival';
1471
1471
  archivedVersion: number;
1472
+ syncStatus: SyncStatus;
1472
1473
  }
1473
1474
 
1474
1475
  interface RemoteArchVerRemovalEvent extends FSEvent {
1475
1476
  type: 'remote-arch-ver-removal';
1476
1477
  removedArchVer: number;
1478
+ syncStatus: SyncStatus;
1477
1479
  }
1478
1480
 
1479
1481
  interface RemoteRemovalEvent extends FSEvent {
1480
1482
  type: 'remote-removal';
1483
+ syncStatus: SyncStatus;
1481
1484
  }
1482
1485
 
1483
1486
  interface RemoteChangeEvent extends FSEvent {
1484
1487
  type: 'remote-change';
1485
- newVersion: number;
1488
+ newRemoteVersion: number;
1489
+ syncStatus: SyncStatus;
1486
1490
  }
1487
1491
 
1488
1492
  type UploadEvent = UploadStartEvent | UploadProgressEvent | UploadDoneEvent;
@@ -33,7 +33,6 @@ const SERVER_EVENTS_RESTART_WAIT_SECS = 5;
33
33
  * events. Someone down the stream can react to these changes from remote.
34
34
  */
35
35
  class RemoteEvents {
36
- // private listeningProc: Subscription|undefined = undefined;
37
36
  constructor(remoteStorage, files, broadcastNodeEvent, logError) {
38
37
  this.remoteStorage = remoteStorage;
39
38
  this.files = files;
@@ -68,19 +67,25 @@ class RemoteEvents {
68
67
  }
69
68
  absorbObjChange(client) {
70
69
  return (new rxjs_1.Observable(obs => client.subscribe(owner_1.events.objChanged.EVENT_NAME, obs)))
71
- .pipe((0, operators_1.mergeMap)(async ({ newVer, objId }) => {
72
- if (!Number.isInteger(newVer) || (newVer < 1)) {
70
+ .pipe((0, operators_1.mergeMap)(async ({ newVer: newRemoteVersion, objId }) => {
71
+ var _a;
72
+ if (!Number.isInteger(newRemoteVersion) || (newRemoteVersion < 1)) {
73
73
  return;
74
74
  }
75
75
  const obj = await this.files.findObj(objId);
76
76
  if (!obj) {
77
77
  return;
78
78
  }
79
- obj.statusObj().recordRemoteChange(newVer);
79
+ const syncStatus = obj.syncStatus().syncStatus();
80
+ if (!((_a = syncStatus.synced) === null || _a === void 0 ? void 0 : _a.latest) || (syncStatus.synced.latest >= newRemoteVersion)) {
81
+ return;
82
+ }
83
+ obj.statusObj().recordRemoteChange(newRemoteVersion);
80
84
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
81
85
  type: 'remote-change',
82
86
  path: '',
83
- newVersion: newVer
87
+ newRemoteVersion,
88
+ syncStatus: obj.syncStatus().syncStatus()
84
89
  });
85
90
  }, 1));
86
91
  }
@@ -94,7 +99,8 @@ class RemoteEvents {
94
99
  obj.statusObj().recordRemoteRemoval();
95
100
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
96
101
  type: 'remote-removal',
97
- path: ''
102
+ path: '',
103
+ syncStatus: obj.syncStatus().syncStatus()
98
104
  });
99
105
  }, 1));
100
106
  }
@@ -109,7 +115,8 @@ class RemoteEvents {
109
115
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
110
116
  type: 'remote-version-archival',
111
117
  path: '',
112
- archivedVersion: archivedVer
118
+ archivedVersion: archivedVer,
119
+ syncStatus: obj.syncStatus().syncStatus()
113
120
  });
114
121
  }, 1));
115
122
  }
@@ -124,7 +131,8 @@ class RemoteEvents {
124
131
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
125
132
  type: 'remote-arch-ver-removal',
126
133
  path: '',
127
- removedArchVer: archivedVer
134
+ removedArchVer: archivedVer,
135
+ syncStatus: obj.syncStatus().syncStatus()
128
136
  });
129
137
  }, 1));
130
138
  }