mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
sync: prepare -> collector, other optimizations
This commit is contained in:
27
packages/core/api/sync/conflicts.js
Normal file
27
packages/core/api/sync/conflicts.js
Normal file
@@ -0,0 +1,27 @@
|
||||
class Conflicts {
|
||||
/**
|
||||
*
|
||||
* @param {import('../index').default} db
|
||||
*/
|
||||
constructor(db) {
|
||||
this._db = db;
|
||||
}
|
||||
|
||||
async recalculate() {
|
||||
if (this._db.notes.conflicted.length <= 0) {
|
||||
await this._db.context.write("hasConflicts", false);
|
||||
}
|
||||
}
|
||||
|
||||
async check() {
|
||||
let hasConflicts = await this._db.context.read("hasConflicts");
|
||||
if (hasConflicts) {
|
||||
const mergeConflictError = new Error(
|
||||
"Merge conflicts detected. Please resolve all conflicts to continue syncing."
|
||||
);
|
||||
mergeConflictError.code = "MERGE_CONFLICT";
|
||||
throw mergeConflictError;
|
||||
}
|
||||
}
|
||||
}
|
||||
export default Conflicts;
|
||||
Reference in New Issue
Block a user