From 11c5ec497398cf1f933c94d95cfc35a1d4f9dbe8 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Mon, 27 Dec 2021 15:36:51 +0530 Subject: [PATCH] Updated standard operations to v2.1.0e --- Layouts/many sections layout/index.html | 18228 +++++++++++----------- 1 file changed, 9138 insertions(+), 9090 deletions(-) diff --git a/Layouts/many sections layout/index.html b/Layouts/many sections layout/index.html index 9588fd6..63ff807 100644 --- a/Layouts/many sections layout/index.html +++ b/Layouts/many sections layout/index.html @@ -179,7384 +179,7409 @@ - - + + + + + TEST_MODE + (use console) + + + return obj1; + } - + + - + - + - + - + - + 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)) + }) + } + } + } + + +