Track fragment versions to reestablish child fragments after a change.

Without this, if I edit, say, post-entry.html, then the actual rendered
post items disappear, because the UI protocol isn't sufficient to allow
replacement of a parent location with survival of a child. I am not sure
if this is a "fix" or a "workaround": it's workaroundish in that in
principle a child fragment could monitor its parent fragment and rebuild
itself when it detects a change. I suspect revision to the UI protocols
is indicated.
This commit is contained in:
Tony Garnock-Jones 2017-03-11 10:54:32 -05:00
parent cddce5a02b
commit 66667d9fe6
1 changed files with 5 additions and 5 deletions

View File

@ -634,10 +634,10 @@
var c = this.ui.context(mainpageVersion, 'post', timestamp, pid);
during inbound(uiTemplate("post-entry.html", $postEntryTemplate)) {
assert c.html('.posts', Mustache.render(postEntryTemplate, postInfo));
during c.fragmentVersion(_) {
during c.fragmentVersion($postEntryVersion) {
var itemCounter = 0;
items.forEach((function (itemURL) {
manifestPostItem(c.context('item', itemCounter++),
manifestPostItem(c.context('item', postEntryVersion, itemCounter++),
'#post-' + pid + ' .post-item-container',
postInfo,
itemURL);
@ -777,12 +777,12 @@
if (entry && !this.entry) this.entry = entry;
}
assert uiContext.html(containerSelector, Mustache.render(postItemTemplate, itemInfo));
on asserted uiContext.fragmentVersion(_) {
var innerContext = uiContext.context('item-body');
on asserted uiContext.fragmentVersion($postItemVersion) {
var innerContext = uiContext.context('item-body', postItemVersion);
assert innerContext.html('#' + itemId + ' .post-item-body-container',
Mustache.render(this.entry, itemInfo)) when (this.entry);
if (!postInfo.isDraft) {
on asserted innerContext.fragmentVersion(_) {
on asserted innerContext.fragmentVersion($innerContextVersion) {
if ((this.latestPostTimestamp === postInfo.timestamp) &&
(this.latestPostId === postInfo.postId)) {
setTimeout(function () { $("#post-" + postInfo.postId)[0].scrollIntoView(false); }, 1);