aboutsummaryrefslogtreecommitdiff
path: root/bog.js
diff options
context:
space:
mode:
Diffstat (limited to 'bog.js')
-rw-r--r--bog.js33
1 files changed, 17 insertions, 16 deletions
diff --git a/bog.js b/bog.js
index 1a45fef..98160c7 100644
--- a/bog.js
+++ b/bog.js
@@ -125,7 +125,7 @@ async function bog (feed) {
// bog.publish -- publishes a new bog post and updates the feeds
// EX: publish({type: 'post', timestamp: Date.now(), text: 'Hello World'}).then(msg => { console.log(msg)})
-async function publish (post, keys) {
+async function publish (post, keys, preview) {
post.author = keys.publicKey
post.timestamp = Date.now()
@@ -146,24 +146,25 @@ async function publish (post, keys) {
var openedMsg = await open(message)
- localforage.getItem('log').then(log => {
- if (log) {
- log.unshift(openedMsg)
- localforage.setItem('log', log)
- } else {
- var feed = [openedMsg]
- localforage.setItem('log', feed)
- }
- })
+ if (!preview) {
+ localforage.getItem('log').then(log => {
+ if (log) {
+ log.unshift(openedMsg)
+ localforage.setItem('log', log)
+ } else {
+ var feed = [openedMsg]
+ localforage.setItem('log', feed)
+ }
+ })
- console.log(keys.publicKey)
+ var subs = [keys.publicKey]
- var subs = [keys.publicKey]
+ feed.unshift(message)
- feed.unshift(message)
- localforage.setItem(keys.publicKey, feed).then(function () {
- sync(subs, keys)
- })
+ localforage.setItem(keys.publicKey, feed).then(function () {
+ sync(subs, keys)
+ })
+ }
return message
} else {