Commit 0df7b2e9903705c4b2201aa29a6a6c1560b102af
only cache old views for maximum of 30 minutes (instead of until restart)
Matt McKegg committed on 11/10/2016, 9:54:27 AMParent: 402f85029889d7cc332cef170ab52fdc69bf4ae4
Files changed
main-window.js | changed |
main-window.js | ||
---|---|---|
@@ -42,8 +42,19 @@ | ||
42 | 42 … | [ssbClient.id]: screenView(ssbClient.id), |
43 | 43 … | '/notifications': screenView('/notifications') |
44 | 44 … | }) |
45 | 45 … | |
46 … | + var lastViewed = {} | |
47 … | + | |
48 … | + // delete cached view after 30 mins of last seeing | |
49 … | + setInterval(() => { | |
50 … | + views.keys().forEach((view) => { | |
51 … | + if (lastViewed[view] !== true && Date.now() - lastViewed[view] > (30 * 60e3) && view !== currentView()) { | |
52 … | + views.delete(view) | |
53 … | + } | |
54 … | + }) | |
55 … | + }, 60e3) | |
56 … | + | |
46 | 57 … | var canGoForward = Value(false) |
47 | 58 … | var canGoBack = Value(false) |
48 | 59 … | var currentView = Value('/public') |
49 | 60 … | |
@@ -95,8 +106,9 @@ | ||
95 | 106 … | // scoped |
96 | 107 … | |
97 | 108 … | function tab (name, view) { |
98 | 109 … | var instance = views.get(view) |
110 … | + lastViewed[view] = true | |
99 | 111 … | return h('a', { |
100 | 112 … | 'ev-click': function (ev) { |
101 | 113 … | if (instance.pendingUpdates && instance.pendingUpdates() && instance.reload) { |
102 | 114 … | instance.reload() |
@@ -135,8 +147,17 @@ | ||
135 | 147 … | function setView (view) { |
136 | 148 … | if (!views.has(view)) { |
137 | 149 … | views.put(view, screenView(view)) |
138 | 150 … | } |
151 … | + | |
152 … | + if (lastViewed[view] !== true) { | |
153 … | + lastViewed[view] = Date.now() | |
154 … | + } | |
155 … | + | |
156 … | + if (currentView() && lastViewed[currentView()] !== true) { | |
157 … | + lastViewed[currentView()] = Date.now() | |
158 … | + } | |
159 … | + | |
139 | 160 … | if (view !== currentView()) { |
140 | 161 … | canGoForward.set(false) |
141 | 162 … | canGoBack.set(true) |
142 | 163 … | forwardHistory.length = 0 |
Built with git-ssb-web