aboutsummaryrefslogtreecommitdiff
path: root/views.js
diff options
context:
space:
mode:
authorEv Bogue <ev@evbogue.com>2020-01-10 09:24:18 -0600
committerEv Bogue <ev@evbogue.com>2020-01-10 09:24:18 -0600
commitdf5dd87b165d3496e808b5ab443ed5f919f3e88c (patch)
treed72768503d07395afdcc6892f9781dda675723de /views.js
parent4614d28969667b6c79a9195ef459942dea3ea546 (diff)
attempt to fix bug where subs end up as null
Diffstat (limited to 'views.js')
-rw-r--r--views.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/views.js b/views.js
index d8c537f..b964915 100644
--- a/views.js
+++ b/views.js
@@ -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()
}