Commit b80b05485ac96a83b8b083d66d87dd14ee6ec93e
Hide old theme versions (per feed + theme name)
Charles Lehner committed on 8/14/2016, 11:55:00 PMParent: 3bd65f71e61cea6de31088772abe36d07aca1deb
Files changed
modules/theme.js | changed |
modules/theme.js | ||
---|---|---|
@@ -85,15 +85,29 @@ | ||
85 | 85 | |
86 | 86 | function theme_view() { |
87 | 87 | var themeInput |
88 | 88 | var themesList = h('form.themes__list') |
89 | + var themesByKey = {} | |
89 | 90 | |
90 | 91 | pull( |
91 | 92 | themes(), |
92 | 93 | 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 | + } | |
96 | 110 | }, function (err) { |
97 | 111 | if (err) console.error(err) |
98 | 112 | }) |
99 | 113 | ) |
Built with git-ssb-web