Create an owned pad and view owned pads in the drive

This commit is contained in:
yflory
2018-01-08 17:36:44 +01:00
parent 1ec41f4e09
commit 0cea5f4596
10 changed files with 131 additions and 21 deletions

View File

@@ -361,6 +361,7 @@ define([
Store.addPad = function (data, cb) {
if (!data.href) { return void cb({error:'NO_HREF'}); }
var pad = makePad(data.href, data.title);
if (data.owners) { pad.owners = data.owners; }
store.userObject.pushData(pad, function (e, id) {
if (e) { return void cb({error: "Error while adding a template:"+ e}); }
var path = data.path || ['root'];
@@ -522,6 +523,11 @@ define([
var p = Hash.parsePadUrl(href);
var h = p.hashData;
var owners;
if (Store.channel && Util.base64ToHex(h.channel) === Store.channel.wc.id) {
owners = Store.channel.data.owners || undefined;
}
var allPads = Util.find(store.proxy, ['drive', 'filesData']) || {};
var isStronger;
@@ -583,6 +589,7 @@ define([
Store.addPad({
href: href,
title: title,
owners: owners,
path: data.path || (store.data && store.data.initialPath)
}, cb);
return;
@@ -735,12 +742,14 @@ define([
// TODO with sharedworker
// channel will be an object storing the webchannel associated to each browser tab
var channel = {
queue: []
var channel = Store.channel = {
queue: [],
data: {}
};
Store.joinPad = function (data, cb) {
var conf = {
onReady: function () {
onReady: function (padData) {
channel.data = padData || {};
postMessage("PAD_READY");
}, // post EV_PAD_READY
onMessage: function (m) {

View File

@@ -36,6 +36,7 @@ define([], function () {
var owners = conf.owners;
var password = conf.password;
var expire = conf.expire;
var padData;
conf = undefined;
var initializing = true;
@@ -43,11 +44,11 @@ define([], function () {
var messageFromOuter = function () {};
var onRdy = function () {
var onRdy = function (padData) {
// Trigger onReady only if not ready yet. This is important because the history keeper sends a direct
// message through "network" when it is synced, and it triggers onReady for each channel joined.
if (!initializing) { return; }
onReady();
onReady(padData);
//sframeChan.event('EV_RT_READY', null);
// we're fully synced
initializing = false;
@@ -92,13 +93,14 @@ define([], function () {
if (parsed.channel === wc.id && !validateKey) {
validateKey = parsed.validateKey;
}
padData = parsed;
// We have to return even if it is not the current channel:
// we don't want to continue with other channels messages here
return;
}
if (parsed.state && parsed.state === 1 && parsed.channel) {
if (parsed.channel === wc.id) {
onRdy();
onRdy(padData);
}
// We have to return even if it is not the current channel:
// we don't want to continue with other channels messages here
@@ -180,7 +182,7 @@ define([], function () {
});
network.historyKeeper = hk;
var cfg = {
var cfg = padData = {
validateKey: validateKey,
lastKnownHash: lastKnownHash,
owners: owners,