Changes to support title change in metadata

pull/1/head
Caleb James DeLisle 7 years ago
parent 604415b32c
commit 415399ef64

@ -15,6 +15,9 @@ define([], function () {
var priv = {}; var priv = {};
var dirty = true; var dirty = true;
var changeHandlers = []; var changeHandlers = [];
var lazyChangeHandlers = [];
var rememberedTitle;
var checkUpdate = function (lazy) { var checkUpdate = function (lazy) {
if (!dirty) { return; } if (!dirty) { return; }
@ -45,11 +48,17 @@ define([], function () {
mdo[meta.user.netfluxId] = meta.user; mdo[meta.user.netfluxId] = meta.user;
metadataObj.users = mdo; metadataObj.users = mdo;
var lazyUserStr = JSON.stringify(metadataLazyObj.users[meta.user.netfluxId]); var lazyUserStr = JSON.stringify(metadataLazyObj.users[meta.user.netfluxId]);
dirty = false;
if (lazy || lazyUserStr !== JSON.stringify(meta.user)) { if (lazy || lazyUserStr !== JSON.stringify(meta.user)) {
metadataLazyObj.users = mdo; metadataLazyObj.users = mdo;
lazyChangeHandlers.forEach(function (f) { f(); });
}
if (metadataObj.title !== rememberedTitle) {
console.log("Title update\n" + metadataObj.title + '\n');
rememberedTitle = metadataObj.title;
} }
dirty = false;
changeHandlers.forEach(function (f) { f(); }); changeHandlers.forEach(function (f) { f(); });
}; };
var change = function (lazy) { var change = function (lazy) {
@ -101,6 +110,7 @@ define([], function () {
return metadataLazyObj; return metadataLazyObj;
}, },
onChange: function (f) { changeHandlers.push(f); }, onChange: function (f) { changeHandlers.push(f); },
onChangeLazy: function (f) { lazyChangeHandlers.push(f); },
isConnected : function () { isConnected : function () {
return members.indexOf(meta.user.netfluxId) !== -1; return members.indexOf(meta.user.netfluxId) !== -1;
}, },

@ -14,6 +14,7 @@ define([
if (ctx.cpNfInner) { return ctx.cpNfInner; } if (ctx.cpNfInner) { return ctx.cpNfInner; }
options.sframeChan = ctx.sframeChan; options.sframeChan = ctx.sframeChan;
ctx.cpNfInner = CpNfInner.start(options); ctx.cpNfInner = CpNfInner.start(options);
ctx.cpNfInner.metadataMgr.onChangeLazy(options.onLocal);
return ctx.cpNfInner; return ctx.cpNfInner;
}; };

@ -347,12 +347,12 @@ define([
defaultTitle: Title.defaultTitle, defaultTitle: Title.defaultTitle,
type: 'pad' type: 'pad'
} }
};*/ };
if (!initializing) { if (!initializing) {
hjson[3].metadata.title = Title.title; hjson[3].metadata.title = Title.title;
} else if (Cryptpad.initialName && !hjson[3].metadata.title) { } else if (Cryptpad.initialName && !hjson[3].metadata.title) {
hjson[3].metadata.title = Cryptpad.initialName; hjson[3].metadata.title = Cryptpad.initialName;
} }*/
return stringify(hjson); return stringify(hjson);
}; };

Loading…
Cancel
Save