diff --git a/www/common/metadata-manager.js b/www/common/metadata-manager.js index 70e9263e5..da3c665d9 100644 --- a/www/common/metadata-manager.js +++ b/www/common/metadata-manager.js @@ -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 }); diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index 9d6529fe1..83a261970 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -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; }); },