Commit 37a6df5a58de74ccdb2f4152cf7272d0eba0d4f9
Merge branch 'themes' of ssb://%Hq+YIFBq9MM1Idy4+IB05MHcVaRgNyG4UJARn8C/2ck=.sha256
Dominic Tarr committed on 9/12/2016, 3:54:34 AMParent: cc5e838dce2fc6b64f1607e8a71f33b4676fc604
Parent: 38af2fdb5719a156793f1114d29328b6f0386cd7
Files changed
modules/theme.js | changed |
modules/theme.js | |||
---|---|---|---|
@@ -47,9 +47,9 @@ | |||
47 | 47 … | ]), | |
48 | 48 … | pull( | |
49 | 49 … | sbot_links2({ | |
50 | 50 … | query: [ | |
51 | - {$filter: {rel: ['mentions', {$prefix: 'patchbay-'}, {$gt: null}]}}, | ||
51 … | + {$filter: {rel: ['mentions', {$prefix: 'patchbay-'}]}}, | ||
52 | 52 … | {$filter: {dest: {$prefix: '&'}}}, | |
53 | 53 … | {$map: {id: 'dest', feed: 'source', name: ['rel', 1]}} | |
54 | 54 … | ], | |
55 | 55 … | live: true, | |
@@ -84,8 +84,14 @@ | |||
84 | 84 … | link.feed ? h('a', {href: '#'+link.feed}, avatar_name(link.feed)) : '' | |
85 | 85 … | ) | |
86 | 86 … | } | |
87 | 87 … | ||
88 … | +function insertAfter(parentNode, newNode, referenceNode) { | ||
89 … | + var nextSibling = referenceNode && referenceNode.nextSibling | ||
90 … | + if (nextSibling) parentNode.insertBefore(newNode, nextSibling) | ||
91 … | + else parentNode.appendChild(newNode) | ||
92 … | +} | ||
93 … | + | ||
88 | 94 … | function theme_view() { | |
89 | 95 … | var themeInput | |
90 | 96 … | var themesList = h('form.themes__list') | |
91 | 97 … | var themesByKey = {} | |
@@ -93,22 +99,23 @@ | |||
93 | 99 … | pull( | |
94 | 100 … | themes(), | |
95 | 101 … | pull.unique('id'), | |
96 | 102 … | pull.drain(function (theme) { | |
97 | - // replace old versions of themes in the list | ||
103 … | + // don't show old versions of theme | ||
98 | 104 … | var key = theme.feed + theme.name | |
99 | - var oldTheme = themesByKey[key] | ||
105 … | + var newerTheme = themesByKey[key] | ||
100 | 106 … | theme.el = renderTheme(theme) | |
101 | 107 … | themesByKey[key] = theme | |
102 | - if (!oldTheme) { | ||
108 … | + if (!newerTheme) { | ||
109 … | + // show latest theme | ||
103 | 110 … | themesList.appendChild(theme.el) | |
104 | - } else if (oldTheme.id === localStorage.themeId | ||
105 | - || oldTheme.id === activeTheme) { | ||
111 … | + } else if (theme.id === localStorage.themeId | ||
112 … | + || theme.id === activeTheme) { | ||
106 | 113 … | // show old version because the user is still using it | |
107 | - oldTheme.el.appendChild(document.createTextNode(' (old)')) | ||
108 | - themesList.appendChild(theme.el) | ||
114 … | + theme.el.appendChild(document.createTextNode(' (old)')) | ||
115 … | + insertAfter(themesList, theme.el, newerTheme.el) | ||
109 | 116 … | } else { | |
110 | - themesList.replaceChild(theme.el, oldTheme.el) | ||
117 … | + // ignore old version of theme | ||
111 | 118 … | } | |
112 | 119 … | }, function (err) { | |
113 | 120 … | if (err) console.error(err) | |
114 | 121 … | }) |
Built with git-ssb-web