Recent pads improvements
This commit is contained in:
@@ -636,7 +636,7 @@ define([
|
||||
}
|
||||
|
||||
// If we have an edit link, check the view link
|
||||
if (el.href && parsed.hashData.type === "pad") {
|
||||
if (el.href && parsed.hashData.type === "pad" && parsed.hashData.version) {
|
||||
if (parsed.hashData.mode === "view") {
|
||||
el.roHref = el.href;
|
||||
delete el.href;
|
||||
@@ -651,6 +651,10 @@ define([
|
||||
}
|
||||
}
|
||||
}
|
||||
// v0 hashes don't support read-only
|
||||
if (parsed.hashData.version === 0) {
|
||||
delete el.roHref;
|
||||
}
|
||||
|
||||
// Fix href
|
||||
if (el.href && /^https*:\/\//.test(el.href)) { el.href = Hash.getRelativeHref(el.href); }
|
||||
|
||||
@@ -961,7 +961,20 @@ define([
|
||||
};
|
||||
|
||||
var getRecentPads = function (Env) {
|
||||
return Env.user.userObject.getRecentPads();
|
||||
var files = [];
|
||||
var userObjects = _getUserObjects(Env);
|
||||
userObjects.forEach(function (uo) {
|
||||
var data = uo.getFiles([UserObject.FILES_DATA]).map(function (id) {
|
||||
return [Number(id), uo.getFileData(id)];
|
||||
});
|
||||
Array.prototype.push.apply(files, data);
|
||||
});
|
||||
var sorted = files.filter(function (a) { return a[1].atime; })
|
||||
.sort(function (a,b) {
|
||||
return b[1].atime - a[1].atime;
|
||||
});
|
||||
return sorted;
|
||||
//return Env.user.userObject.getRecentPads();
|
||||
};
|
||||
var getOwnedPads = function (Env) {
|
||||
return Env.user.userObject.getOwnedPads(Env.edPublic);
|
||||
|
||||
@@ -95,6 +95,8 @@ define([
|
||||
exp.isReadOnlyFile = function (element) {
|
||||
if (!isFile(element)) { return false; }
|
||||
var data = exp.getFileData(element);
|
||||
// undefined means this pad doesn't support read-only
|
||||
if (!data.roHref) { return; }
|
||||
return Boolean(data.roHref && !data.href);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user