git ssb

10+

Matt McKegg / patchwork



Commit 7e44e13afc44b6b906290606afe84a7c45b33eff

append own root posts directly to rollup without refresh

Matt McKegg committed on 6/25/2018, 1:49:11 AM
Parent: aae000974cbf50d2a0e3bcee4440ca9e6e5f7b26

Files changed

modules/feed/html/rollup.jschanged
modules/feed/html/rollup.jsView
@@ -118,22 +118,29 @@
118118 newSinceRefresh.add(msg.key)
119119 unreadIds.add(msg.key)
120120 }
121121
122- if (updates() === 0 && msg.value.author === yourId && container.scrollTop < 500) {
123- refresh()
124- } else if (msg.value.author === yourId && content()) {
122+ if (msg.value.author === yourId && content()) {
125123 // dynamically insert this post into the feed! (manually so that it doesn't get slow with mutant)
126- var existingContainer = content().querySelector(`[data-root-id="${msg.value.content.root}"]`)
127- if (existingContainer) {
128- var replies = existingContainer.querySelector('div.replies')
129- var lastReply = existingContainer.querySelector('div.replies > .Message:last-child')
130- var previousId = lastReply ? lastReply.getAttribute('data-id') : existingContainer.getAttribute('data-root-id')
131- replies.appendChild(api.message.html.render(msg, {
132- previousId,
133- compact: false,
134- priority: 2
135- }))
124+ if (api.message.sync.root(msg)) {
125+ var existingContainer = content().querySelector(`[data-root-id="${api.message.sync.root(msg)}"]`)
126+ if (existingContainer) {
127+ var replies = existingContainer.querySelector('div.replies')
128+ var lastReply = existingContainer.querySelector('div.replies > .Message:last-child')
129+ var previousId = lastReply ? lastReply.getAttribute('data-id') : existingContainer.getAttribute('data-root-id')
130+ replies.appendChild(api.message.html.render(msg, {
131+ previousId,
132+ compact: false,
133+ priority: 2
134+ }))
135+ }
136+ } else {
137+ highlightItems.add(msg.key)
138+ content().prepend(
139+ renderItem(extend(msg, {
140+ replies: []
141+ }))
142+ )
136143 }
137144 }
138145
139146 updates.set(newSinceRefresh.size)

Built with git-ssb-web