2020-04-16 03:04:44 +05:00
|
|
|
class Conflicts {
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param {import('../index').default} db
|
|
|
|
|
*/
|
|
|
|
|
constructor(db) {
|
|
|
|
|
this._db = db;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async recalculate() {
|
|
|
|
|
if (this._db.notes.conflicted.length <= 0) {
|
2021-09-26 11:47:13 +05:00
|
|
|
await this._db.storage.write("hasConflicts", false);
|
2020-04-16 03:04:44 +05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async check() {
|
2021-09-26 11:47:13 +05:00
|
|
|
let hasConflicts = await this._db.storage.read("hasConflicts");
|
2020-04-16 03:04:44 +05:00
|
|
|
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;
|