main-window.jsView |
---|
71 | 71 | |
72 | 72 | var lastViewed = {} |
73 | 73 | var defaultViews = views.keys() |
74 | 74 | |
75 | | - |
| 75 | + |
76 | 76 | setInterval(() => { |
77 | 77 | views.keys().forEach((view) => { |
78 | 78 | if (!defaultViews.includes(view)) { |
79 | 79 | if (lastViewed[view] !== true && Date.now() - lastViewed[view] > (5 * 60e3) && view !== currentView()) { |
86 | 86 | var canGoForward = Value(false) |
87 | 87 | var canGoBack = Value(false) |
88 | 88 | var currentView = Value('/public') |
89 | 89 | |
90 | | - var mainElement = h('div.main', MutantMap(toCollection(views), (item) => { |
| 90 | + var viewCollection = toCollection(views) |
| 91 | + |
| 92 | + var mainElement = h('div.main', MutantMap(viewCollection, (item) => { |
91 | 93 | return h('div.view', { |
92 | 94 | hidden: computed([item.key, currentView], (a, b) => a !== b) |
93 | 95 | }, [ item.value ]) |
94 | 96 | })) |
190 | 192 | } |
191 | 193 | |
192 | 194 | function goBack () { |
193 | 195 | if (backHistory.length) { |
| 196 | + |
194 | 197 | canGoForward.set(true) |
195 | 198 | forwardHistory.push(currentView()) |
196 | | - currentView.set(backHistory.pop()) |
| 199 | + |
| 200 | + var view = backHistory.pop() |
| 201 | + if (!views.has(view)) { |
| 202 | + views.put(view, renderPage(view)) |
| 203 | + } |
| 204 | + |
| 205 | + currentView.set(view) |
197 | 206 | canGoBack.set(backHistory.length > 0) |
198 | 207 | } |
199 | 208 | } |
200 | 209 | |
201 | 210 | function goForward () { |
202 | 211 | if (forwardHistory.length) { |
203 | 212 | backHistory.push(currentView()) |
204 | | - currentView.set(forwardHistory.pop()) |
| 213 | + |
| 214 | + var view = forwardHistory.pop() |
| 215 | + if (!views.has(view)) { |
| 216 | + views.put(view, renderPage(view)) |
| 217 | + } |
| 218 | + |
| 219 | + currentView.set(view) |
205 | 220 | canGoForward.set(forwardHistory.length > 0) |
206 | 221 | canGoBack.set(true) |
207 | 222 | } |
208 | 223 | } |