Commit 6a98dbefa275e1234eb09fc437ac1a2a914c29da
dynamically insert your own new posts into rollup
fixes #719 improves #709Matt McKegg committed on 2/12/2018, 3:47:09 AM
Parent: 5a4a6a832bb38f133e2c2062cfeeac1e81969854
Files changed
modules/feed/html/rollup.js | changed |
modules/feed/html/rollup.js | ||
---|---|---|
@@ -118,11 +118,24 @@ | ||
118 | 118 | } |
119 | 119 | |
120 | 120 | if (updates() === 0 && msg.value.author === yourId && container.scrollTop < 20) { |
121 | 121 | refresh() |
122 | - } else { | |
123 | - updates.set(newSinceRefresh.size) | |
122 | + } else if (msg.value.author === yourId && content()) { | |
123 | + // dynamically insert this post into the feed! (manually so that it doesn't get slow with mutant) | |
124 | + var existingContainer = content().querySelector(`[data-root-id="${msg.value.content.root}"]`) | |
125 | + if (existingContainer) { | |
126 | + var replies = existingContainer.querySelector('div.replies') | |
127 | + var lastReply = existingContainer.querySelector('div.replies > .Message:last-child') | |
128 | + var previousId = lastReply ? lastReply.getAttribute('data-id') : existingContainer.getAttribute('data-root-id') | |
129 | + replies.appendChild(api.message.html.render(msg, { | |
130 | + previousId, | |
131 | + compact: false, | |
132 | + priority: 2 | |
133 | + })) | |
134 | + } | |
124 | 135 | } |
136 | + | |
137 | + updates.set(newSinceRefresh.size) | |
125 | 138 | }) |
126 | 139 | ) |
127 | 140 | }) |
128 | 141 |
Built with git-ssb-web