Get all pad attributes at once

pull/1/head
yflory 5 years ago
parent 4708d59a65
commit 6e5fdc0b8e

@ -71,56 +71,22 @@ define([
var getPropertiesData = function (common, cb) { var getPropertiesData = function (common, cb) {
var data = {}; var data = {};
NThen(function (waitFor) { NThen(function (waitFor) {
common.getPadAttribute('password', waitFor(function (err, val) {
data.password = val;
}));
}).nThen(function (waitFor) {
var base = common.getMetadataMgr().getPrivateData().origin; var base = common.getMetadataMgr().getPrivateData().origin;
// XXX getFileData? common.getPadAttribute('', waitFor(function (err, val) {
// XXX getPadMetadata if (err || !val) {
common.getPadAttribute('href', waitFor(function (err, val) { waitFor.abort();
if (!val) { return; } return void cb(err || 'EEMPTY');
data.href = base + val; }
})); Util.extend(data, val);
common.getPadAttribute('roHref', waitFor(function (err, val) { if (data.href) { data.href = base + data.href; }
if (!val) { return; } if (data.roHref) { data.roHref = base + data.roHref; }
data.roHref = base + val;
}));
common.getPadAttribute('channel', waitFor(function (err, val) {
data.channel = val;
}));
common.getPadAttribute('rtChannel', waitFor(function (err, val) {
data.rtChannel = val;
}));
common.getPadAttribute('lastVersion', waitFor(function (err, val) {
data.lastVersion = val;
}));
common.getPadAttribute('atime', waitFor(function (err, val) {
data.atime = val;
}));
common.getPadAttribute('ctime', waitFor(function (err, val) {
data.ctime = val;
}));
common.getPadAttribute('title', waitFor(function (err, val) {
data.title = val;
}));
common.getPadAttribute('tags', waitFor(function (err, val) {
data.tags = val;
})); }));
common.getPadMetadata(null, waitFor(function (obj) { common.getPadMetadata(null, waitFor(function (obj) {
console.log(obj);
if (obj && obj.error) { return; } if (obj && obj.error) { return; }
data.owners = obj.owners; data.owners = obj.owners;
data.expire = obj.expire; data.expire = obj.expire;
data.pending_owners = obj.pending_owners; data.pending_owners = obj.pending_owners;
})); }));
/*
common.getPadAttribute('owners', waitFor(function (err, val) {
data.owners = val;
}));
common.getPadAttribute('expire', waitFor(function (err, val) {
data.expire = val;
}));*/
}).nThen(function () { }).nThen(function () {
cb(void 0, data); cb(void 0, data);
}); });

@ -738,29 +738,17 @@ define([
return void cb(null, Env.user.proxy[UserObject.SHARED_FOLDERS][sfId][data.attr]); return void cb(null, Env.user.proxy[UserObject.SHARED_FOLDERS][sfId][data.attr]);
} }
var datas = findHref(Env, data.href); var datas = findHref(Env, data.href);
var nt = nThen;
var res = {}; var res = {};
datas.forEach(function (d) { datas.forEach(function (d) {
nt = nt(function (waitFor) { var atime = d.data.atime;
var atime, value;
var w = waitFor(); var value = attr ? d.data[attr] : JSON.parse(JSON.stringify(d.data));
nThen(function (waitFor2) {
d.userObject.getPadAttribute(data.href, 'atime', waitFor2(function (err, v) {
atime = v;
}));
d.userObject.getPadAttribute(data.href, data.attr, waitFor2(function (err, v) {
value = v;
}));
}).nThen(function () {
if (!res.value || res.atime < atime) { if (!res.value || res.atime < atime) {
res.atime = atime; res.atime = atime;
res.value = value; res.value = value;
} }
w();
});
}).nThen;
}); });
nt(function () { cb(null, res.value); }); cb(null, res.value);
}; };
var getTagsList = function (Env) { var getTagsList = function (Env) {

Loading…
Cancel
Save