fixed one last fight
parent
9c0b0cc6a8
commit
33e73dd5e5
|
@ -2,7 +2,6 @@ define([], function () {
|
|||
var UNINIT = 'uninitialized';
|
||||
var create = function (sframeChan) {
|
||||
var meta = UNINIT;
|
||||
var myID = UNINIT;
|
||||
var members = [];
|
||||
var metadataObj = UNINIT;
|
||||
var dirty = true;
|
||||
|
@ -11,27 +10,27 @@ define([], function () {
|
|||
var checkUpdate = function () {
|
||||
if (!dirty) { return; }
|
||||
if (meta === UNINIT) { throw new Error(); }
|
||||
if (myID === UNINIT) { myID = meta.myID; }
|
||||
if (metadataObj === UNINIT) {
|
||||
metadataObj = {
|
||||
defaultTitle: meta.doc.defaultTitle,
|
||||
title: meta.doc.defaultTitle,
|
||||
type: meta.doc.type,
|
||||
users: {}
|
||||
};
|
||||
}
|
||||
var mdo = {};
|
||||
// We don't want to add our user data to the object multiple times.
|
||||
var containsYou = false;
|
||||
console.log(metadataObj);
|
||||
//console.log(metadataObj);
|
||||
Object.keys(metadataObj.users).forEach(function (x) {
|
||||
if (members.indexOf(x) === -1) { return; }
|
||||
mdo[x] = metadataObj.users[x];
|
||||
if (metadataObj.users[x].uid === meta.user.uid) {
|
||||
console.log('document already contains you');
|
||||
//console.log('document already contains you');
|
||||
containsYou = true;
|
||||
}
|
||||
});
|
||||
if (!containsYou) { mdo[myID] = meta.user; }
|
||||
if (!containsYou) { mdo[meta.user.netfluxId] = meta.user; }
|
||||
metadataObj.users = mdo;
|
||||
dirty = false;
|
||||
changeHandlers.forEach(function (f) { f(); });
|
||||
|
@ -46,7 +45,7 @@ define([], function () {
|
|||
change();
|
||||
});
|
||||
sframeChan.on('EV_RT_CONNECT', function (ev) {
|
||||
myID = ev.myID;
|
||||
meta.user.netfluxId = ev.myID;
|
||||
members = ev.members;
|
||||
change();
|
||||
});
|
||||
|
|
|
@ -622,6 +622,10 @@ define([
|
|||
|
||||
// Update the user list (metadata) from the hyperjson
|
||||
// XXX Metadata.update(shjson);
|
||||
var parsed = JSON.parse(shjson);
|
||||
if (parsed[3] && parsed[3].metadata) {
|
||||
cpNfInner.metadataMgr.updateMetadata(parsed[3].metadata);
|
||||
}
|
||||
|
||||
if (!readOnly) {
|
||||
var shjson2 = stringifyDOM(inner);
|
||||
|
|
|
@ -19,10 +19,11 @@ define([
|
|||
Cryptpad.ready(waitFor());
|
||||
}).nThen(function (waitFor) {
|
||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||
parsed.type = parsed.type.replace('pad2', 'pad');
|
||||
if (!parsed.type) { throw new Error(); }
|
||||
var defaultTitle = Cryptpad.getDefaultName(parsed);
|
||||
var updateMeta = function () {
|
||||
console.log('EV_METADATA_UPDATE');
|
||||
//console.log('EV_METADATA_UPDATE');
|
||||
var name;
|
||||
nThen(function (waitFor) {
|
||||
Cryptpad.getLastName(waitFor(function (n) { name = n }));
|
||||
|
@ -32,13 +33,13 @@ define([
|
|||
defaultTitle: defaultTitle,
|
||||
type: parsed.type
|
||||
},
|
||||
myID: Cryptpad.getNetwork().webChannels[0].myID,
|
||||
user: {
|
||||
name: name,
|
||||
uid: Cryptpad.getUid(),
|
||||
avatar: Cryptpad.getAvatarUrl(),
|
||||
profile: Cryptpad.getProfileUrl(),
|
||||
curvePublic: Cryptpad.getProxy().curvePublic
|
||||
curvePublic: Cryptpad.getProxy().curvePublic,
|
||||
netfluxId: Cryptpad.getNetwork().webChannels[0].myID,
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue