From 59218260abcc762ea2c81dc6b60aefd7c5d69593 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Mon, 27 Dec 2021 15:40:31 +0530 Subject: [PATCH] Updated Standard Operations to v2.1.0e --- Layouts/sidebar layout/index.html | 9856 +++++++++++++++-------------- 1 file changed, 4951 insertions(+), 4905 deletions(-) diff --git a/Layouts/sidebar layout/index.html b/Layouts/sidebar layout/index.html index 92fca98..7e98238 100644 --- a/Layouts/sidebar layout/index.html +++ b/Layouts/sidebar layout/index.html @@ -85,247 +85,252 @@ - + + + + + TEST_MODE + (use console) + + - - - /*obj is original object or array, diff is the output of findDiff */ - window.mergeDiff = (obj, diff) => { - if (Object.keys(diff.updated).length !== 0) - obj = mergeRecursive(obj, diff.updated) - if (Object.keys(diff.deleted).length !== 0) { - obj = mergeRecursive(obj, diff.deleted) - obj = cleanse(obj) - } - if (Object.keys(diff.added).length !== 0) - obj = mergeRecursive(obj, diff.added) - return obj - } - })(); - + - + - + - + - + - + this.getNextGeneralData[fk] = Object.keys(filteredResult).sort().pop(); + return filteredResult; + }, - \ No newline at end of file + syncData: { + oldDevice: function() { + return new Promise((resolve, reject) => { + let sync = { + contacts: floGlobals.contacts, + pubKeys: floGlobals.pubKeys, + messages: floGlobals.messages + } + let message = Crypto.AES.encrypt(JSON.stringify(sync), myPrivKey) + let options = { + receiverID: myFloID, + application: "floDapps" + } + floCloudAPI.sendApplicationData(message, "syncData", options) + .then(result => resolve(result)) + .catch(error => reject(error)) + }) + }, + + newDevice() { + return new Promise((resolve, reject) => { + var options = { + receiverID: myFloID, + senderIDs: myFloID, + application: "floDapps", + mostRecent: true, + } + floCloudAPI.requestApplicationData("syncData", options).then(response => { + let vc = Object.keys(response).sort().pop() + let sync = JSON.parse(Crypto.AES.decrypt(response[vc].message, myPrivKey)) + let promises = [] + let store = (key, val, obs) => promises.push(compactIDB.writeData(obs, val, key, `floDapps#${floID}`)); + ["contacts", "pubKeys", "messages"].forEach(c => { + for (let i in sync[c]) { + store(i, sync[c][i], c) + floGlobals[c][i] = sync[c][i] + } + }) + Promise.all(promises) + .then(results => resolve("Sync data successful")) + .catch(error => reject(error)) + }).catch(error => reject(error)) + }) + } + } + } + + +