From 225132d80c2e60719d39ca95e0750f1dcf6dd54e Mon Sep 17 00:00:00 2001 From: Ev Bogue Date: Fri, 19 Jul 2019 09:44:35 -0500 Subject: prevent blank identifications -- which seem to happen often --- app.js | 23 ++++++++++++----------- index.html | 2 +- views.js | 24 +++++++++++++----------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/app.js b/app.js index 7371102..c15f2f2 100644 --- a/app.js +++ b/app.js @@ -23,19 +23,20 @@ function route (keys) { input, h('button', { onclick: function () { - content = { - type: 'name', - named: id, - name: input.value - } - console.log('GETTING NAME') - publish(content, keys) - setTimeout(function () { - getName(id, keys) + if (input.value) { + content = { + type: 'name', + named: id, + name: input.value + } + publish(content, keys) setTimeout(function () { - location.reload() + getName(id, keys) + setTimeout(function () { + location.reload() + }, 1000) }, 1000) - }, 1000) + } } }, ['Identify']) ])) diff --git a/index.html b/index.html index 59e731e..6a30f2f 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - + diff --git a/views.js b/views.js index 8b5922d..56cee4a 100644 --- a/views.js +++ b/views.js @@ -23,18 +23,20 @@ function profilePage (src, keys) { input, h('button', { onclick: function () { - content = { - type: 'name', - named: src, - name: input.value - } - localforage.removeItem('name:' + src) - publish(content, keys).then(post => { - open(post).then(msg => { - input.value = '' - scroller.insertBefore(render(msg, keys), scroller.childNodes[1]) + if (input.value) { + content = { + type: 'name', + named: src, + name: input.value + } + localforage.removeItem('name:' + src) + publish(content, keys).then(post => { + open(post).then(msg => { + input.value = '' + scroller.insertBefore(render(msg, keys), scroller.childNodes[1]) + }) }) - }) + } } }, ['Identify']) ]) -- cgit v1.2.3-70-g09d2