git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit 89f33f4a320148796631bda325c47c569d9630e6

Merge branch 'themes' of ssb://%Hq+YIFBq9MM1Idy4+IB05MHcVaRgNyG4UJARn8C/2ck=.sha256 into styles

Ev Bogue committed on 9/8/2016, 3:53:59 PM
Parent: a2d77f538ad8f6a8aa9df1f3bbc8ddf3f3e180f3
Parent: d8fcc8b35fe6c7280e3c86cbb20788534c0f34f1

Files changed

modules/theme.jschanged
modules/theme.jsView
@@ -84,8 +84,14 @@
8484 link.feed ? h('a', {href: '#'+link.feed}, avatar_name(link.feed)) : ''
8585 )
8686 }
8787
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 +
8894 function theme_view() {
8995 var themeInput
9096 var themesList = h('form.themes__list')
9197 var themesByKey = {}
@@ -93,22 +99,23 @@
9399 pull(
94100 themes(),
95101 pull.unique('id'),
96102 pull.drain(function (theme) {
97- // replace old versions of themes in the list
103 + // don't show old versions of theme
98104 var key = theme.feed + theme.name
99- var oldTheme = themesByKey[key]
105 + var newerTheme = themesByKey[key]
100106 theme.el = renderTheme(theme)
101107 themesByKey[key] = theme
102- if (!oldTheme) {
108 + if (!newerTheme) {
109 + // show latest theme
103110 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) {
106113 // 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)
109116 } else {
110- themesList.replaceChild(theme.el, oldTheme.el)
117 + // ignore old version of theme
111118 }
112119 }, function (err) {
113120 if (err) console.error(err)
114121 })

Built with git-ssb-web