git ssb

16+

Dominic / patchbay



Commit cba374c25c373104effa4eb8d66f3c376c6518df

Merge branch 'master' into fix-reply-quote-in-threads

Anders Rune Jensen committed on 8/8/2018, 7:00:35 PM
Parent: 51cce4b91688bab9a65aaab93e4e95848d30f84b
Parent: 372af7ef0364ce311abbfd591690266f8fc41e35

Files changed

app/html/search-bar.jschanged
app/page/blogs.jsadded
package-lock.jsonchanged
router/sync/routes.jschanged
app/html/search-bar.jsView
@@ -72,9 +72,9 @@
7272
7373 // TODO extract
7474 function getPagesSuggestions (word) {
7575 const pages = [
76- 'calendar', 'posts', 'public', 'private', 'inbox', 'profile', 'notifications', 'settings',
76 + 'blogs', 'calendar', 'posts', 'public', 'private', 'inbox', 'profile', 'notifications', 'settings',
7777 'gatherings', 'chess', 'books', 'imageSearch', 'polls', 'query'
7878 ]
7979
8080 return pages
app/page/blogs.jsView
@@ -1,0 +1,92 @@
1 +const nest = require('depnest')
2 +const { h } = require('mutant')
3 +// const pull = require('pull-stream')
4 +const Scroller = require('mutant-scroll')
5 +const next = require('pull-next-query')
6 +
7 +exports.gives = nest({
8 + 'app.html.menuItem': true,
9 + 'app.page.blogs': true
10 +})
11 +
12 +exports.needs = nest({
13 + 'message.html.render': 'first',
14 + 'sbot.pull.stream': 'first'
15 +})
16 +
17 +exports.create = function (api) {
18 + return nest({
19 + 'app.html.menuItem': menuItem,
20 + 'app.page.blogs': blogsPage
21 + })
22 +
23 + function menuItem () {
24 + return h('a', {
25 + style: { order: 1 },
26 + 'ev-click': () => api.app.sync.goTo({ page: 'blogs' })
27 + }, '/blogs')
28 + }
29 +
30 + function blogsPage (location) {
31 + const createStream = (opts) => {
32 + const query = [{
33 + $filter: {
34 + timestamp: { $gt: 0 },
35 + value: {
36 + content: { type: 'blog' }
37 + }
38 + }
39 + }]
40 + return api.sbot.pull.stream(server => {
41 + return next(server.query.read, Object.assign({}, { limit: 100, query }, opts), ['timestamp'])
42 + })
43 + }
44 + var page = Scroller({
45 + classList: ['Blogs'],
46 + streamToTop: createStream({ live: true, old: false }),
47 + streamToBottom: createStream({ reverse: true }),
48 + render: api.message.html.render
49 + })
50 +
51 + page.title = '/blogs'
52 + page.scroll = keyscroll(page.querySelector('section.content'))
53 + return page
54 + }
55 +}
56 +
57 +// copied from app.html.scroller
58 +function keyscroll (content) {
59 + var curMsgEl
60 +
61 + if (!content) return () => {}
62 +
63 + content.addEventListener('click', onActivateChild, false)
64 + content.addEventListener('focus', onActivateChild, true)
65 +
66 + function onActivateChild (ev) {
67 + for (var el = ev.target; el; el = el.parentNode) {
68 + if (el.parentNode === content) {
69 + curMsgEl = el
70 + return
71 + }
72 + }
73 + }
74 +
75 + return function scroll (d) {
76 + selectChild((!curMsgEl || d === 'first') ? content.firstChild
77 + : d < 0 ? curMsgEl.previousElementSibling || content.firstChild
78 + : d > 0 ? curMsgEl.nextElementSibling || content.lastChild
79 + : curMsgEl)
80 +
81 + return curMsgEl
82 + }
83 +
84 + function selectChild (el) {
85 + if (!el) { return }
86 +
87 + if (!el.scrollIntoViewIfNeeded && !el.scrollIntoView) return
88 + ;(el.scrollIntoViewIfNeeded || el.scrollIntoView).call(el)
89 + el.focus()
90 + curMsgEl = el
91 + }
92 +}
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 292918 bytes
New file size: 293309 bytes
router/sync/routes.jsView
@@ -6,8 +6,9 @@
66 exports.needs = nest({
77 'app.page': {
88 'calendar': 'first',
99 'blob': 'first',
10 + 'blogs': 'first',
1011 'errors': 'first',
1112 'channel': 'first',
1213 'imageSearch': 'first',
1314 'notifications': 'first',
@@ -29,8 +30,9 @@
2930 const pages = api.app.page
3031
3132 // loc = location
3233 const routes = [
34 + [ loc => loc.page === 'blogs', pages.blogs ],
3335 [ loc => loc.page === 'calendar', pages.calendar ],
3436 [ loc => loc.page === 'errors', pages.errors ],
3537 [ loc => loc.page === 'imageSearch', pages.imageSearch ],
3638 [ loc => loc.page === 'notifications', pages.notifications ],

Built with git-ssb-web