Update userlist and title in history mode

pull/1/head
yflory 4 years ago
parent e6bcd71d89
commit 8e77d77925

@ -14,6 +14,7 @@ define(['json.sortify'], function (Sortify) {
var metadataLazyObj = UNINIT; var metadataLazyObj = UNINIT;
var priv = {}; var priv = {};
var dirty = true; var dirty = true;
var history = false;
var changeHandlers = []; var changeHandlers = [];
var lazyChangeHandlers = []; var lazyChangeHandlers = [];
var titleChangeHandlers = []; var titleChangeHandlers = [];
@ -60,7 +61,7 @@ define(['json.sortify'], function (Sortify) {
var mdo = {}; var mdo = {};
// We don't want to add our user data to the object multiple times. // We don't want to add our user data to the object multiple times.
Object.keys(metadataObj.users).forEach(function (x) { Object.keys(metadataObj.users).forEach(function (x) {
if (members.indexOf(x) === -1) { return; } if (members.indexOf(x) === -1 && !history) { return; }
mdo[x] = metadataObj.users[x]; mdo[x] = metadataObj.users[x];
}); });
if (!priv.readOnly) { if (!priv.readOnly) {
@ -161,6 +162,9 @@ define(['json.sortify'], function (Sortify) {
metadataLazyObj = JSON.parse(JSON.stringify(m)); metadataLazyObj = JSON.parse(JSON.stringify(m));
change(false); change(false);
}, },
refresh : function () {
change(true);
},
updateTitle: function (t) { updateTitle: function (t) {
metadataObj.title = t; metadataObj.title = t;
change(true); change(true);
@ -207,6 +211,9 @@ define(['json.sortify'], function (Sortify) {
if (isReady) { return void f(); } if (isReady) { return void f(); }
readyHandlers.push(f); readyHandlers.push(f);
}, },
setHistory: function (bool) {
history = bool;
}
}); });
}; };
return Object.freeze({ create: create }); return Object.freeze({ create: create });

@ -262,8 +262,12 @@ define([
}; };
var setHistoryMode = function (bool, update) { var setHistoryMode = function (bool, update) {
cpNfInner.metadataMgr.setHistory(bool);
stateChange((bool) ? STATE.HISTORY_MODE : STATE.READY); stateChange((bool) ? STATE.HISTORY_MODE : STATE.READY);
if (!bool && update) { onRemote(); } if (!bool && update) { onRemote(); }
else {
setTimeout(cpNfInner.metadataMgr.refresh);
}
}; };
/* /*
@ -692,7 +696,10 @@ define([
onRemote: onRemote, onRemote: onRemote,
setHistory: setHistoryMode, setHistory: setHistoryMode,
applyVal: function (val) { applyVal: function (val) {
contentUpdate(JSON.parse(val) || ["BODY",{},[]], function (h) { var newContent = JSON.parse(val);
var meta = extractMetadata(newContent);
cpNfInner.metadataMgr.updateMetadata(meta);
contentUpdate(normalize(newContent) || ["BODY",{},[]], function (h) {
return h; return h;
}); });
}, },

Loading…
Cancel
Save