Prototype

pull/1/head
yflory 4 years ago
parent 7ab529d4e9
commit d81e1f3ecd

@ -499,6 +499,7 @@ define([
var isNew = function () { var isNew = function () {
error = undefined; error = undefined;
postMessage('IS_NEW_CHANNEL', {channel: channel}, function (obj) { postMessage('IS_NEW_CHANNEL', {channel: channel}, function (obj) {
console.error(obj);
if (obj && obj.error) { error = obj.error; } if (obj && obj.error) { error = obj.error; }
if (!obj) { error = "INVALID_RESPONSE"; } if (!obj) { error = "INVALID_RESPONSE"; }
@ -2271,8 +2272,9 @@ define([
localToken: tryParsing(localStorage.getItem(Constants.tokenKey)), // TODO move this to LocalStore ? localToken: tryParsing(localStorage.getItem(Constants.tokenKey)), // TODO move this to LocalStore ?
language: common.getLanguage(), language: common.getLanguage(),
cache: rdyCfg.cache, cache: rdyCfg.cache,
noDrive: rdyCfg.noDrive,
disableCache: localStorage['CRYPTPAD_STORE|disableCache'], disableCache: localStorage['CRYPTPAD_STORE|disableCache'],
driveEvents: true //rdyCfg.driveEvents // Boolean driveEvents: !rdyCfg.noDrive //rdyCfg.driveEvents // Boolean
}; };
common.userHash = userHash; common.userHash = userHash;

@ -547,6 +547,7 @@ define([
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
var getAllStores = Store.getAllStores = function () { var getAllStores = Store.getAllStores = function () {
if (!store.proxy) { return []; }
var stores = [store]; var stores = [store];
var teamModule = store.modules['team']; var teamModule = store.modules['team'];
if (teamModule) { if (teamModule) {
@ -568,7 +569,7 @@ define([
getColor().toString(16); getColor().toString(16);
}; };
var getUserColor = function () { var getUserColor = function () {
var color = Util.find(store.proxy, ['settings', 'general', 'cursor', 'color']); var color = Util.find(store, ['proxy', 'settings', 'general', 'cursor', 'color']);
if (!color) { if (!color) {
color = getRandomColor(); color = getRandomColor();
Store.setAttribute(null, { Store.setAttribute(null, {
@ -581,33 +582,34 @@ define([
// Get the metadata for sframe-common-outer // Get the metadata for sframe-common-outer
Store.getMetadata = function (clientId, app, cb) { Store.getMetadata = function (clientId, app, cb) {
var disableThumbnails = Util.find(store.proxy, ['settings', 'general', 'disableThumbnails']); var proxy = store.proxy || {};
var disableThumbnails = Util.find(proxy, ['settings', 'general', 'disableThumbnails']);
var teams = (store.modules['team'] && store.modules['team'].getTeamsData(app)) || {}; var teams = (store.modules['team'] && store.modules['team'].getTeamsData(app)) || {};
var metadata = { var metadata = {
// "user" is shared with everybody via the userlist // "user" is shared with everybody via the userlist
user: { user: {
name: store.proxy[Constants.displayNameKey] || "", name: proxy[Constants.displayNameKey] || "",
uid: store.proxy.uid, uid: proxy.uid,
avatar: Util.find(store.proxy, ['profile', 'avatar']), avatar: Util.find(proxy, ['profile', 'avatar']),
profile: Util.find(store.proxy, ['profile', 'view']), profile: Util.find(proxy, ['profile', 'view']),
color: getUserColor(), color: getUserColor(),
notifications: Util.find(store.proxy, ['mailboxes', 'notifications', 'channel']), notifications: Util.find(proxy, ['mailboxes', 'notifications', 'channel']),
curvePublic: store.proxy.curvePublic, curvePublic: proxy.curvePublic,
}, },
// "priv" is not shared with other users but is needed by the apps // "priv" is not shared with other users but is needed by the apps
priv: { priv: {
clientId: clientId, clientId: clientId,
edPublic: store.proxy.edPublic, edPublic: proxy.edPublic,
friends: store.proxy.friends || {}, friends: proxy.friends || {},
settings: store.proxy.settings, settings: proxy.settings || NEW_USER_SETTINGS,
thumbnails: disableThumbnails === false, thumbnails: disableThumbnails === false,
isDriveOwned: Boolean(Util.find(store, ['driveMetadata', 'owners'])), isDriveOwned: Boolean(Util.find(store, ['driveMetadata', 'owners'])),
support: Util.find(store.proxy, ['mailboxes', 'support', 'channel']), support: Util.find(proxy, ['mailboxes', 'support', 'channel']),
driveChannel: store.driveChannel, driveChannel: store.driveChannel,
pendingFriends: store.proxy.friends_pending || {}, pendingFriends: proxy.friends_pending || {},
supportPrivateKey: Util.find(store.proxy, ['mailboxes', 'supportadmin', 'keys', 'curvePrivate']), supportPrivateKey: Util.find(proxy, ['mailboxes', 'supportadmin', 'keys', 'curvePrivate']),
accountName: store.proxy.login_name || '', accountName: proxy.login_name || '',
offline: store.offline, offline: store.proxy && store.offline,
teams: teams, teams: teams,
plan: account.plan plan: account.plan
} }
@ -1632,6 +1634,7 @@ define([
}; };
Store.joinPad = function (clientId, data) { Store.joinPad = function (clientId, data) {
console.error('JOINPAD');
if (data.versionHash) { if (data.versionHash) {
return void getVersionHash(clientId, data); return void getVersionHash(clientId, data);
} }
@ -1708,6 +1711,7 @@ define([
postMessage(clientId, "PAD_CACHE_READY"); postMessage(clientId, "PAD_CACHE_READY");
}, },
onReady: function (pad) { onReady: function (pad) {
console.warn(pad);
var padData = pad.metadata || {}; var padData = pad.metadata || {};
channel.data = padData; channel.data = padData;
if (padData && padData.validateKey && store.messenger) { if (padData && padData.validateKey && store.messenger) {
@ -1768,8 +1772,10 @@ define([
channel: data.channel, channel: data.channel,
metadata: data.metadata, metadata: data.metadata,
network: store.network || store.networkPromise, network: store.network || store.networkPromise,
websocketURL: NetConfig.getWebsocketURL(),
//readOnly: data.readOnly, //readOnly: data.readOnly,
onConnect: function (wc, sendMessage) { onConnect: function (wc, sendMessage) {
console.warn('CONNECT');
channel.sendMessage = function (msg, cId, cb) { channel.sendMessage = function (msg, cId, cb) {
// Send to server // Send to server
sendMessage(msg, function (err) { sendMessage(msg, function (err) {
@ -2636,7 +2642,7 @@ define([
loadUniversal(Messenger, 'messenger', waitFor); loadUniversal(Messenger, 'messenger', waitFor);
store.messenger = store.modules['messenger']; store.messenger = store.modules['messenger'];
loadUniversal(Profile, 'profile', waitFor); loadUniversal(Profile, 'profile', waitFor);
store.modules['team'].onReady(waitFor); if (store.modules['team']) { store.modules['team'].onReady(waitFor); }
loadUniversal(History, 'history', waitFor); loadUniversal(History, 'history', waitFor);
}).nThen(function () { }).nThen(function () {
var requestLogin = function () { var requestLogin = function () {
@ -2748,6 +2754,11 @@ define([
return void cb({error: '[Store.init] Unable to find or create a drive hash. Aborting...'}); return void cb({error: '[Store.init] Unable to find or create a drive hash. Aborting...'});
} }
var lock = false;
if (!data.userHash && !data.anonHash) {
lock = true;
}
var updateProgress = function (data) { var updateProgress = function (data) {
data.type = 'drive'; data.type = 'drive';
postMessage(clientId, 'LOADING_DRIVE', data); postMessage(clientId, 'LOADING_DRIVE', data);
@ -2767,6 +2778,7 @@ define([
userName: 'fs', userName: 'fs',
logLevel: 1, logLevel: 1,
ChainPad: ChainPad, ChainPad: ChainPad,
lock: lock,
updateProgress: updateProgress, updateProgress: updateProgress,
classic: true, classic: true,
}; };
@ -2914,6 +2926,7 @@ define([
*/ */
var initialized = false; var initialized = false;
var noDrive = [];
Store.init = function (clientId, data, _callback) { Store.init = function (clientId, data, _callback) {
var callback = Util.once(_callback); var callback = Util.once(_callback);
@ -2948,7 +2961,6 @@ define([
Cache.disable(); Cache.disable();
} }
initialized = true;
postMessage = function (clientId, cmd, d, cb) { postMessage = function (clientId, cmd, d, cb) {
data.query(clientId, cmd, d, cb); data.query(clientId, cmd, d, cb);
}; };
@ -2956,6 +2968,18 @@ define([
data.broadcast(excludes, cmd, d, cb); data.broadcast(excludes, cmd, d, cb);
}; };
// First tab, no user hash, no anon hash and this app doesn't need a drive
// ==> don't create a drive
if (data.noDrive && !data.userHash && !data.anonHash) {
noDrive.push(clientId);
// XXX We need a network before initAnonRpc...
return void initAnonRpc(null, null, function () {
callback({});
});
}
initialized = true;
store.data = data; store.data = data;
connect(clientId, data, function (ret) { connect(clientId, data, function (ret) {
if (Object.keys(store.proxy).length === 1) { if (Object.keys(store.proxy).length === 1) {

@ -16,6 +16,7 @@ define([
}).nThen(function (/*waitFor*/) { }).nThen(function (/*waitFor*/) {
SFCommonO.start({ SFCommonO.start({
cache: true, cache: true,
noDrive: true,
hash: hash, hash: hash,
href: href, href: href,
useCreationScreen: true, useCreationScreen: true,

@ -152,6 +152,7 @@ define([
cb('OK'); cb('OK');
}); });
sframeChan.on('EV_RT_READY', function () { sframeChan.on('EV_RT_READY', function () {
console.error('INNER READY');
if (isReady) { return; } if (isReady) { return; }
if (updateLoadingProgress) { if (updateLoadingProgress) {
updateLoadingProgress({ updateLoadingProgress({

@ -222,6 +222,7 @@ define([
} catch (e) { console.error(e); } } catch (e) { console.error(e); }
Cryptpad.ready(waitFor(), { Cryptpad.ready(waitFor(), {
noDrive: cfg.noDrive,
driveEvents: cfg.driveEvents, driveEvents: cfg.driveEvents,
cache: Boolean(cfg.cache), cache: Boolean(cfg.cache),
currentPad: currentPad currentPad: currentPad
@ -486,6 +487,7 @@ define([
} }
// Not a file, so we can use `isNewChannel` // Not a file, so we can use `isNewChannel`
Cryptpad.isNewChannel(currentPad.href, password, w(function(e, isNew) { Cryptpad.isNewChannel(currentPad.href, password, w(function(e, isNew) {
alert('ko');
if (isNew && expire && expire < (+new Date())) { if (isNew && expire && expire < (+new Date())) {
sframeChan.event("EV_EXPIRED_ERROR"); sframeChan.event("EV_EXPIRED_ERROR");
waitFor.abort(); waitFor.abort();

Loading…
Cancel
Save