(
otherClientId: IdOrNull = null,
otherContentHashes?: ContentHashes,
transactionId: Id = getTransactionId(),
)
| 153 | }; |
| 154 | |
| 155 | const getChangesFromOtherStore = ( |
| 156 | otherClientId: IdOrNull = null, |
| 157 | otherContentHashes?: ContentHashes, |
| 158 | transactionId: Id = getTransactionId(), |
| 159 | ): Promise<MergeableChanges | void> => |
| 160 | tryCatch(async () => { |
| 161 | if (isUndefined(otherContentHashes)) { |
| 162 | [otherContentHashes, otherClientId, transactionId] = |
| 163 | await request<ContentHashes>( |
| 164 | null, |
| 165 | MessageValues.GetContentHashes, |
| 166 | EMPTY_STRING, |
| 167 | transactionId, |
| 168 | ); |
| 169 | } |
| 170 | const [otherTablesHash, otherValuesHash] = otherContentHashes; |
| 171 | const [tablesHash, valuesHash] = store.getMergeableContentHashes(); |
| 172 | |
| 173 | let tablesChanges: TablesStamp = stampNewObj(); |
| 174 | if (tablesHash != otherTablesHash) { |
| 175 | const [newTables, differentTableHashes] = ( |
| 176 | await request<[TablesStamp, TableHashes]>( |
| 177 | otherClientId, |
| 178 | MessageValues.GetTableDiff, |
| 179 | store.getMergeableTableHashes(), |
| 180 | transactionId, |
| 181 | ) |
| 182 | )[0]; |
| 183 | tablesChanges = newTables; |
| 184 | |
| 185 | if (!objIsEmpty(differentTableHashes)) { |
| 186 | const [newRows, differentRowHashes] = ( |
| 187 | await request<[TablesStamp, RowHashes]>( |
| 188 | otherClientId, |
| 189 | MessageValues.GetRowDiff, |
| 190 | store.getMergeableRowHashes(differentTableHashes), |
| 191 | transactionId, |
| 192 | ) |
| 193 | )[0]; |
| 194 | mergeTablesStamps(tablesChanges, newRows); |
| 195 | |
| 196 | if (!objIsEmpty(differentRowHashes)) { |
| 197 | const newCells = ( |
| 198 | await request<TablesStamp>( |
| 199 | otherClientId, |
| 200 | MessageValues.GetCellDiff, |
| 201 | store.getMergeableCellHashes(differentRowHashes), |
| 202 | transactionId, |
| 203 | ) |
| 204 | )[0]; |
| 205 | mergeTablesStamps(tablesChanges, newCells); |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | return [ |
| 211 | tablesChanges, |
| 212 | valuesHash == otherValuesHash |
no test coverage detected
searching dependent graphs…