git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit b80b05485ac96a83b8b083d66d87dd14ee6ec93e

Hide old theme versions (per feed + theme name)

Charles Lehner committed on 8/14/2016, 11:55:00 PM
Parent: 3bd65f71e61cea6de31088772abe36d07aca1deb

Files changed

modules/theme.jschanged
modules/theme.jsView
@@ -85,15 +85,29 @@
8585
8686 function theme_view() {
8787 var themeInput
8888 var themesList = h('form.themes__list')
89+ var themesByKey = {}
8990
9091 pull(
9192 themes(),
9293 pull.unique('id'),
93- pull.map(renderTheme),
94- pull.drain(function (el) {
95- themesList.appendChild(el)
94+ pull.drain(function (theme) {
95+ // replace old versions of themes in the list
96+ var key = theme.feed + theme.name
97+ var oldTheme = themesByKey[key]
98+ theme.el = renderTheme(theme)
99+ themesByKey[key] = theme
100+ if (!oldTheme) {
101+ themesList.appendChild(theme.el)
102+ } else if (oldTheme.id === localStorage.themeId
103+ || oldTheme.id === activeTheme) {
104+ // show old version because the user is still using it
105+ oldTheme.el.appendChild(document.createTextNode(' (old)'))
106+ themesList.appendChild(theme.el)
107+ } else {
108+ themesList.replaceChild(theme.el, oldTheme.el)
109+ }
96110 }, function (err) {
97111 if (err) console.error(err)
98112 })
99113 )

Built with git-ssb-web