www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

storageResult.js (1504B)


      1 "use strict";
      2 
      3 /**
      4  * @property {Boolean} localChanges - Changes were made locally. For logging purposes only.
      5  * @property {Boolean} remoteChanges - Changes were made on the server. This causes the
      6  *     last-sync time to be updated on the server (WebDAV) or retrieved (ZFS) and stored locally
      7  *     to skip additional file syncs until further server changes are made.
      8  * @property {Boolean} syncRequired - A data sync is required to upload local changes
      9  * @propretty {Boolean} fileSyncRequired - Another file sync is required to handle files left in
     10  *     conflict
     11  */
     12 Zotero.Sync.Storage.Result = function (options = {}) {
     13 	this._props = ['localChanges', 'remoteChanges', 'syncRequired', 'fileSyncRequired'];
     14 	for (let prop of this._props) {
     15 		this[prop] = options[prop] || false;
     16 	}
     17 }
     18 
     19 /**
     20  * Update the properties on this object from multiple Result objects
     21  *
     22  * @param {Zotero.Sync.Storage.Result[]} results
     23  */
     24 Zotero.Sync.Storage.Result.prototype.updateFromResults = function (results) {
     25 	for (let prop of this._props) {
     26 		if (!this[prop]) {
     27 			for (let result of results) {
     28 				if (!(result instanceof Zotero.Sync.Storage.Result)) {
     29 					Zotero.debug(result, 1);
     30 					throw new Error("'result' is not a storage result");
     31 				}
     32 				if (result[prop]) {
     33 					this[prop] = true;
     34 				}
     35 			}
     36 		}
     37 	}
     38 }
     39 
     40 
     41 Zotero.Sync.Storage.Result.prototype.toString = function () {
     42 	var obj = {};
     43 	for (let prop of this._props) {
     44 		obj[prop] = this[prop] || false;
     45 	}
     46 	return JSON.stringify(obj, null, "    ");
     47 }