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

@ -262,8 +262,12 @@ define([
};
var setHistoryMode = function (bool, update) {
cpNfInner.metadataMgr.setHistory(bool);
stateChange((bool) ? STATE.HISTORY_MODE : STATE.READY);
if (!bool && update) { onRemote(); }
else {
setTimeout(cpNfInner.metadataMgr.refresh);
}
};
/*
@ -692,7 +696,10 @@ define([
onRemote: onRemote,
setHistory: setHistoryMode,
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;
});
},

Loading…
Cancel
Save