Files
notesnook/packages/core/api/sync/conflicts.js
2020-04-16 03:04:44 +05:00

28 lines
635 B
JavaScript

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;