diff options
author | Ev Bogue <ev@evbogue.com> | 2020-01-10 09:24:18 -0600 |
---|---|---|
committer | Ev Bogue <ev@evbogue.com> | 2020-01-10 09:24:18 -0600 |
commit | df5dd87b165d3496e808b5ab443ed5f919f3e88c (patch) | |
tree | d72768503d07395afdcc6892f9781dda675723de /views.js | |
parent | 4614d28969667b6c79a9195ef459942dea3ea546 (diff) |
attempt to fix bug where subs end up as null
Diffstat (limited to 'views.js')
-rw-r--r-- | views.js | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -138,7 +138,13 @@ function searchPage (src, keys) { function publicPage (keys) { - localforage.getItem('subscriptions').then(function (subs) { + localforage.getItem('log').then(log => { + log.sort((a, b) => a.timestamp - b.timestamp) + var reversed = log.reverse() + localforage.setItem('log', reversed) + }) + + localforage.getItem('subscriptions').then(subs => { var interval = 1000 timer = function() { if ('' === window.location.hash.substring(1)) { @@ -148,9 +154,17 @@ function publicPage (keys) { } } if (subs) { + // the next two lines just fix a bug where the first sub was being set to null. Delete this code after March 2020. + subs.forEach(sub => { + if (sub == null) { + var subs = [keys.publicKey] + localforage.setItem('subscriptions', subs) + } + }) timer() } else { - var subs = [keys.publickey] + var subs = [keys.publicKey] + console.log(subs) localforage.setItem('subscriptions', subs) timer() } |