git ssb

10+

Matt McKegg / patchwork



Commit 6a98dbefa275e1234eb09fc437ac1a2a914c29da

dynamically insert your own new posts into rollup

fixes #719
improves #709
Matt McKegg committed on 2/12/2018, 3:47:09 AM
Parent: 5a4a6a832bb38f133e2c2062cfeeac1e81969854

Files changed

modules/feed/html/rollup.jschanged
modules/feed/html/rollup.jsView
@@ -118,11 +118,24 @@
118118 }
119119
120120 if (updates() === 0 && msg.value.author === yourId && container.scrollTop < 20) {
121121 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+ }
124135 }
136+
137+ updates.set(newSinceRefresh.size)
125138 })
126139 )
127140 })
128141

Built with git-ssb-web