mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-21 14:09:34 +01:00
28 lines
635 B
JavaScript
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;
|