clean up serverside and clientside pinning logic

This commit is contained in:
ansuz
2017-04-07 15:20:30 +02:00
parent fdede0d1fd
commit a2f692b9a3
3 changed files with 56 additions and 91 deletions

View File

@@ -10,12 +10,16 @@ define([
};
var synchronize = function (call) {
var localHash = call.localChannelsHash();
// provide a sorted list of unique channels
var list = Cryptpad.deduplicateString(Cryptpad.getUserChannelList())
.sort();
var localHash = call.hashChannelList(list);
var serverHash;
call.getFileListSize(function (e, bytes) {
if (e) { return void console.error(e); }
console.log("%s total bytes used", bytes);
console.log("total %sK bytes used", bytes / 1000);
});
call.getServerHash(function (e, hash) {
@@ -26,7 +30,7 @@ define([
return console.log("all your pads are pinned. There is nothing to do");
}
call.reset(function (e, response) {
call.reset(list, function (e, response) {
if (e) { return console.error(e); }
else {
return console.log('reset pin list. new hash is [%s]', response);
@@ -37,7 +41,10 @@ define([
$(function () {
Cryptpad.ready(function (err, env) {
Pinpad.create(function (e, call) {
var network = Cryptpad.getNetwork();
var proxy = Cryptpad.getStore().getProxy().proxy;
Pinpad.create(network, proxy, function (e, call) {
if (e) { return void console.error(e); }
synchronize(call);
});